public function store(FrontUserRequest $request) { $user = new User(); $user->email = $request->get('email'); $user->first_name = $request->get('first_name'); $user->last_name = $request->get('last_name'); $user->locale = $request->get('locale', 'nl'); $user->role = UserRole::MEMBER(); $user->status = UserStatus::ACTIVE(); $user->save(); $eventDescription = $this->getEventDescriptionFor('created', $user); activity($eventDescription); flash()->success(strip_tags($eventDescription) . '. ' . fragment('back.members.passwordMailSent')); event(new UserCreatedThroughBack($user)); return redirect()->action('Back\\MembersController@index'); }
<?php use App\Services\Auth\Front\Enums\UserRole; use App\Services\Auth\Front\Enums\UserStatus; use App\Services\Auth\Front\User; $factory->define(User::class, function () { $person = faker()->person(); return ['first_name' => $person['firstName'], 'last_name' => $person['lastName'], 'email' => $person['email'], 'password' => app()->environment('local') ? strtolower($person['firstName']) : faker()->password, 'locale' => 'nl', 'role' => UserRole::MEMBER(), 'status' => UserStatus::ACTIVE(), 'address' => faker()->address, 'postal' => faker()->postcode, 'city' => faker()->city, 'country' => faker()->country, 'telephone' => faker()->phoneNumber]; });
public function setRoleAttribute(UserRole $role) { $this->attributes['role'] = $role->getValue(); }