我重写了create()
Eloquent 方法,但是当我尝试调用它时,我得到了Cannot make static method Illuminate\\Database\\Eloquent\\Model::create() non static in class MyModel
.
我这样调用create()
方法:
$f = new MyModel();
$f->create([
'post_type_id' => 1,
'to_user_id' => Input::get('toUser'),
'from_user_id' => 10,
'message' => Input::get('message')
]);
在MyModel
课堂上我有这个:
public function create($data) {
if (!Namespace\Auth::isAuthed())
throw new Exception("You can not create a post as a guest.");
parent::create($data);
}
为什么这不起作用?我应该改变什么才能让它工作?