Hello so I am a beginner in laravel and having some problems. I am not using Illuminate html for my forms because I want just plain html forms. I'm getting this Use of undefined constant id - assumed 'id'
in my edit.blade.php
. Here is my 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>
And in my controller
:
public function getBook($id) {
$book = Books::findOrFail($id);
return view('books.edit', compact('book'));
}
Am I doing something wrong?
Ok so I fixed it by myself.
First thing is I changed the line
{{$book.id}}
to{{$book->id}}
. Second is to edit .env with this values:Then restart server
php artisan serve
.