Laravel错误“模型/模型名称的声明应与Illuminate \ Database \ Eloquent \ Model兼容". [英] Laravel error "Declaration of model/model_name should be compatible with Illuminate\Database\Eloquent\Model"
问题描述
我面对有关laravel应用的一个奇怪的问题.在生产服务器上更新Composer之后,出现此错误.我的登录页面显示正常,当我输入凭据时,它显示此错误,或者凭据错误或对,它始终显示相同的错误.
错误是
App \ Models \ User :: update($ a_data = NULL,$ a_conditions = NULL)的声明应与Illuminate \ Database \ Eloquent \ Model :: update(array $ attributes = Array,array $ options = Array )
我在互联网上进行了搜索,但一无所获.请帮忙.会很感激的.
从父类覆盖方法时-方法的签名就参数及其类型而言必须完全相同/p>
在父类中,$attributes
和$options
都设置为array
类型,因此您还必须在您的类中设置这种设置方式
namespace App\Models;
class User extends \Illuminate\Database\Eloquent\Model {
...
public function update(array $attributes = [], array $options = []) {
// ... your implementation
return parent::update($attributes, $options);
}
...
}
i am facing a strange issue regarding laravel application. after updating the composer on my production server i am getting this error. My login page showing fine and when i am entering the credentials its showing this error either the credentials wrong or right its always showing the same error.
Error is
Declaration of App\Models\User::update($a_data = NULL, $a_conditions = NULL) should be compatible with Illuminate\Database\Eloquent\Model::update(array $attributes = Array, array $options = Array)
i have searched on internet but found nothing. Please do help. will be thankful.
When overriding a method from parent class - the signature of the method must be exactly the same in terms of parameters and their types
In the parent class, both $attributes
and $options
are set to be of type array
, so you must also set set them this way in your class
namespace App\Models;
class User extends \Illuminate\Database\Eloquent\Model {
...
public function update(array $attributes = [], array $options = []) {
// ... your implementation
return parent::update($attributes, $options);
}
...
}
这篇关于Laravel错误“模型/模型名称的声明应与Illuminate \ Database \ Eloquent \ Model兼容".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!