Recently I've started with Laravel 5.8 and I'm trying to make the edit button which will update the row from the database. and when the edit button click, Laravel raise an error like this

![](https://i.stack.imgur.com/cCfZ1.png)

this is my Controller:

```php
    public function edit($id_book){
        $book = Books::find($id_book);
        return view('/books',['book'->$book]);
    }

    public function UploadEdit(Request $request){
        DB::table('books')->where('id_book',$request->id_book)->update([
            'judul' => $request->judul,
            'gambar' => $request->gambar,
            'kategori' => $request->kategori,
            'deskripsi' => $request->deskripsi,
            'ketersediaan' => $request->ketersediaan,
            'lokasi' => $request->lokasi
        ]);

        return redirect()->back();
    }

```

this is my models:

```php
    class Books extends Model
    {
        protected $table = "books";
        protected $primaryKey = "id_book";

       protected $fillable = [
           'judul',
           'gambar',
           'kategori',
           'deskripsi',
           'ketersediaan',
           'lokasi'
       ];
    }

```

I was trying to solve this problem with change edit function in the controller:
from this

```php
    public function edit($id_book){
        $book = Books::find($id_book);
        return view('/books',['book'->$book]);
    }

```

to this

```php
    public function edit($id_book){
        $book = Books::find($id_book);
        return view('/books',compact('book'));
    }

```

and this:

```php
    public function edit($id_book){
         $book = Books::find($id_book);
         return view('/books')->withBooks('$book');
    }

```

but it doesn't work