2

First,I call artisan tinker using the command below

$ php artisan tinker


Then, I plan to get all of the model in Admin to update the name as "admin", then I save the update by using command below

$admin = App\Admin::get()->name="admin"->save()

//Admin is my model
//name is the table structure of Admin table
//then I save it with save()


However, it pop out an error as shown below :-

PHP Error: Call to a member function save() on string in Psy Shell code on line 1

Darush
  • 11,403
  • 9
  • 62
  • 60
Ho Wei Kang
  • 101
  • 2
  • 10

2 Answers2

5

With update method.

$admin = App\Admin::query()->update(['name' => 'admin']);

In Admin model:

protected $fillable = 'name';
Volkan Yılmaz
  • 539
  • 3
  • 10
0

The problem with the code is that you're chaining a method on a string.

Use update next time, like this:

$admin = App\Admin::get()->update(['name' => 'admin'])

Read more on this here.