Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 尝试插入数据时出现此错误消息将[name]添加到可填充属性以允许对[App\SuiteSpecialist]进行批量分配_Laravel_Post_Get_Laravel 6 - Fatal编程技术网

Laravel 尝试插入数据时出现此错误消息将[name]添加到可填充属性以允许对[App\SuiteSpecialist]进行批量分配

Laravel 尝试插入数据时出现此错误消息将[name]添加到可填充属性以允许对[App\SuiteSpecialist]进行批量分配,laravel,post,get,laravel-6,Laravel,Post,Get,Laravel 6,谁能给我解释一下为什么控制器会出错 这是我的模型: class Suitspecialist extends Authenticatable { use Notifiable; protected $guard = 'suitspecialist'; protected $fillable = [ 'name', 'email', 'password', ]; protected $hidden = [ 'password'

谁能给我解释一下为什么控制器会出错

这是我的模型:

class Suitspecialist extends Authenticatable
{
    use Notifiable;
    protected $guard = 'suitspecialist';
    protected $fillable = [
        'name', 'email', 'password',
    ];
    protected $hidden = [
        'password', 'remember_token',
    ];
}
控制器

这部分抛出一个错误

将[name]添加到可填充属性以允许对[App\SuiteSpecialist]进行批量分配


您不能同时使用
保护的
可填充的
。最好只使用
filleable

当您尝试使用fill、create或update等方法填充模型上的严重属性时,需要指定可以这样填充的字段。这就是所谓的“大规模分配”

这是一个雄辩的安全实现,以避免您存储不想存储的数据

在您的模型中,使用
保护的
可填充的
属性指定希望或不希望注册的特性使用体量指定。这些属性接受一个数组


请参阅Laravel文档,其中有很好的解释:

您可能需要清除缓存:运行
composer dump autoload
composer clear cache
php artisan cache:clear
,甚至可能是一个
php artisan路由:clear
。我尝试过,但仍然抛出相同的错误remove
protected$guard='suitespecialist'
tryOk,只是为了确保:您在这个项目中只有一个suitespecialist类?它位于应用程序名称空间/文件夹下?谢谢Rob!我刚发现
protected function createSuitspecialist(Request $request)
{
    $this->validator($request->all())->validate();
    Suitspecialist::create([
        'name' => $request->name,
        'email' => $request->email,
        'password' => Hash::make($request->password),
    ]);
    return redirect()->intended('login/suitspecialist');
}