【问题标题】:Laravel Use of undefined constant in formLaravel 在表单中使用未定义的常量
【发布时间】:2015-06-13 04:41:25
【问题描述】:

您好,我是 laravel 的初学者,遇到了一些问题。我没有为我的表单使用 Illuminate html,因为我只想要普通的 html 表单。我在我的edit.blade.php 中收到了这个Use of undefined constant id - assumed 'id'。这是我的edit.blade.php

<form action="/books/{{$book.id}}/update" method="POST">
    Title: <input type="text" name="title"> <br/>
   Author: <input type="text" name="author"> <br/>
    ISBN: <input type="text" name="isbn"> <br/>
        <input type="hidden" name="_method" value="PUT">
        <input type="hidden" name="_token" value="{{ csrf_token() }}">
    <input type="submit">
</form>

在我的controller:

public function getBook($id) {
    $book = Books::findOrFail($id);
    return view('books.edit', compact('book'));
}

我做错了吗?

【问题讨论】:

    标签: laravel lumen


    【解决方案1】:

    好的,我自己修好了。

    首先我将{{$book.id}} 改为{{$book-&gt;id}}。 其次是使用以下值编辑 .env:

    CACHE_DRIVER=array
    SESSION_DRIVER=cookie
    QUEUE_DRIVER=array
    

    然后重启服务器php artisan serve

    【讨论】:

      猜你喜欢
      • 2014-04-23
      • 1970-01-01
      • 1970-01-01
      • 2021-09-23
      • 2019-02-10
      • 1970-01-01
      • 1970-01-01
      • 2019-09-30
      • 1970-01-01
      相关资源
      最近更新 更多