По какой-то причине метод create не принимает переданный массив, когда я пытаюсь создать нового пользователя.
Я получаю следующую ошибку:
SQLSTATE[HY000]: General error: 1364 Field 'first_name' doesn't have a default value (SQL: insert into `users` (`updated_at`, `created_at`) values (2018-05-30 13:24:33, 2018-05-30 13:24:33))
Это текущий код:
public function storeUser($data, $request)
{
if($request->hasFile('avatar'))
$data['avatar'] = $this->uploadAvatar($request->file('avatar'));
$password = \Hash::make($data['temp_password']);
$data['password'] = $password;
$data['temporary_password'] = $password;
$data['social'] = Strings::arrayToJson($data['social']);
// Assign the clinic_id from the select menu (only super admin have the permission to do this)
if(\Auth::user()->hasRole('super_admin') && isset($data['clinic_user']))
$data['clinic_id'] = (int) $data['clinic_user'];
// If the admin of the clinic is creating the user we wiil use his clinic_id for the new user
if(\Auth::user()->hasRole('admin'))
$data['clinic_id'] = \Auth::user()->clinic_id;
if($this->create($data)){
event(new NewUser($this, $data['temp_password']));
if(\Auth::user()->hasRole('super_admin') && isset($data['clinic_owner']))
event(new ClinicUpdate($this));
if(\Auth::user()->hasRole('super_admin', 'admin') && \Auth::user()->id !== $this->id)
$user->giveRole($data['user_role']);
return true;
}
return false;
}
Модель пользователя:
Подробнее здесь: https://stackoverflow.com/questions/506 ... cept-array
Laravel 5.6 – красноречивое создание не принимает массив ⇐ Php
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Laravel 7 – запретить красноречивое отношение из базы данных запроса, если оно равно нулю
Anonymous » » в форуме Php - 0 Ответы
- 21 Просмотры
-
Последнее сообщение Anonymous
-