Request::all('search', 'role', 'trashed'), 'users' => Auth::user()->account->users() ->orderByName() ->filter(Request::only('search', 'role', 'trashed')) ->get() ->transform(function ($user) { return [ 'id' => $user->id, 'name' => $user->name, 'email' => $user->email, 'owner' => $user->owner, 'deleted_at' => $user->deleted_at, ]; }), ]); } public function create() { return Inertia::render('Users/Create'); } public function store() { return Auth::user()->account->users()->create( Request::validate([ 'first_name' => ['required', 'max:50'], 'last_name' => ['required', 'max:50'], 'email' => ['required', 'max:50', 'email', Rule::unique('users')], 'password' => ['nullable'], 'owner' => ['required', 'boolean'], ]) )->only('id'); } public function edit(User $user) { return Inertia::render('Users/Edit', [ 'user' => [ 'id' => $user->id, 'first_name' => $user->first_name, 'last_name' => $user->last_name, 'email' => $user->email, 'owner' => $user->owner, 'deleted_at' => $user->deleted_at, ], ]); } public function update(User $user) { Request::validate([ 'first_name' => ['required', 'max:50'], 'last_name' => ['required', 'max:50'], 'email' => ['required', 'max:50', 'email', Rule::unique('users')->ignore($user->id)], 'password' => ['nullable'], 'owner' => ['required', 'boolean'], ]); $user->update(Request::only('first_name', 'last_name', 'email', 'owner')); if (Request::get('password')) { $user->update(['password' => Request::get('password')]); } } public function destroy(User $user) { $user->delete(); } public function restore(User $user) { $user->restore(); } }