using(function (array $data) { $data['password'] = $data['password']; $role_id = Role::where('name', $data['role'])->first()->id; $data = array_merge($data, ['role_id' => $role_id]); return User::create($data); }), ]; } }