get(); } public function getUserById($userId) { return User::findOrFail($userId); } public function create(array $userDetails, array $role) { $user = User::create($userDetails); $user->roles()->attach($role); return $user; } public function update($userId, array $newDetails, array $role) { $user = User::whereId($userId)->update($newDetails); $user->roles()->sync($role); return $user; } public function delete($userId) { $user = User::whereId($userId)->first(); $user->roles()->detach(); return $user->destroy(); } }