How will the user replace? You're transferring charcoal value.$fillable Only that when you call methods save()♪ create()♪ update() (and other similar) only those fields which are specified (e.g. field) may be modified id No one can change under any pretext, or you have another logic where the field must be strictly static.As soon as you and the rivervest begin to accept it, only then you have to check what you get and where you come from, and until then there's no cause for concern (fucking, if you don't give everyone the right to your code, but then it's the least of the problems you're facing).That's the option. dangerous.:protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'alpha_dash', 'string', 'min:4', 'max:18', 'unique:users'],
'password' => ['required', 'string', 'min:4', 'max:18'],
//'role' => ['required', 'numeric', 'in:1'], - это обезопасит любое действие пользователя, но нет смысла давать ему такое, пока у Вас может быть только одна допустимая роль при отправке формы
]);
}
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'password' => Hash::make($data['password']),
'role' => $data['role'], //Возможна подстановка любого значения, если нет проверки в валидации
]);
}
The default option in the database is appropriate, but may be uncomfortable. Moreover, sooner or later, you'll still be transferring not only the first role.