Call to undefined method Illuminate\Database\Query\Builder::save()

前端 未结 3 1655
伪装坚强ぢ
伪装坚强ぢ 2021-02-07 06:53

I am trying to call Eloquent\'s save() method on an existing record but getting an error from Illuminate\'s Query Builder.

Following the documentation on Laravel\'s web

3条回答
  •  没有蜡笔的小新
    2021-02-07 07:03

    you have to fetch your model after given an ->where

    $this->employee = Employee::where('login', $login)->get();
    

    or

    $this->employee = Employee::where('login', $login)->first();
    

    if you don't do that your Object $this->employee would't be one and you could not use ->save()

提交回复
热议问题