I override the create() Eloquent method, but when I try to call it, I get the Cannot make static method Illuminate\\Database\\Eloquent\\Model::create() non static in class MyModel .
I call the create() method as follows:
$f = new MyModel(); $f->create([ 'post_type_id' => 1, 'to_user_id' => Input::get('toUser'), 'from_user_id' => 10, 'message' => Input::get('message') ]);
And in the MyModel class, I have this:
public function create($data) { if (!Namespace\Auth::isAuthed()) throw new Exception("You can not create a post as a guest."); parent::create($data); }
Why is this not working? What should I change to make it work?
source share