withPageTitle(trans('dashboard.team.team').' - '.trans('dashboard.dashboard')) ->withTeamMembers($team); } /** * Shows the edit team member view. * * @return \Illuminate\View\View */ public function showTeamMemberView(User $user) { return View::make('dashboard.team.edit') ->withPageTitle(trans('dashboard.team.edit.title').' - '.trans('dashboard.dashboard')) ->withUser($user); } /** * Shows the add team member view. * * @return \Illuminate\View\View */ public function showAddTeamMemberView() { return View::make('dashboard.team.add') ->withPageTitle(trans('dashboard.team.add.title').' - '.trans('dashboard.dashboard')); } /** * Creates a new team member. * * @return \Illuminate\Http\RedirectResponse */ public function postAddUser() { try { $this->dispatch(new AddTeamMemberCommand( Binput::get('username'), Binput::get('password'), Binput::get('email'), Binput::get('level') )); } catch (ValidationException $e) { return Redirect::route('dashboard.team.add') ->withInput(Binput::except('password')) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.add.failure'))) ->withErrors($e->getMessageBag()); } return Redirect::route('dashboard.team.add') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.add.success'))); } /** * Updates a user. * * @param \CachetHQ\Cachet\Models\User $user * * @return \Illuminate\View\View */ public function postUpdateUser(User $user) { $items = Binput::all(); $passwordChange = array_get($items, 'password'); if (trim($passwordChange) === '') { unset($items['password']); } try { $user->update($items); } catch (ValidationException $e) { return Redirect::route('dashboard.team.edit', ['id' => $user->id]) ->withInput(Binput::except('password')) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.edit.failure'))) ->withErrors($e->getMessageBag()); } return Redirect::route('dashboard.team.edit', ['id' => $user->id]) ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.edit.success'))); } /** * Delete a user. * * @param \CachetHQ\Cachet\Models\User $user * * @return \Illuminate\Http\RedirectResponse */ public function deleteUser(User $user) { $this->dispatch(new RemoveUserCommand($user)); return Redirect::route('dashboard.team.index') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.delete.success'))); } }