2

I'm trying to use the code provided by the documentation of entrust in a controller but save() method wont execute and gives me the error

Method [save] does not exist on [App\Http\Controllers\role]

Here is the code:

$cityadmin = new Role();
$cityadmin->name= 'cityadmin';
$cityadmin->save();
LazyOne
  • 158,824
  • 45
  • 388
  • 391
the inquisitor
  • 99
  • 1
  • 1
  • 4

1 Answers1

0

Use full namespace:

$cityadmin = new \App\Role;

Or add this to the top of the controller:

use App\Role;
Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279