/** * Returns all users that are not assigned in the current project. * * @return array */ public function usersNotIn() { if ($this->id > 0) { $userIds = $this->users()->lists('user_id')->all(); $users = User::where('deleted', '=', User::NOT_DELETED_USERS)->whereNotIn('id', $userIds)->get(); } else { $users = User::where('deleted', '=', User::NOT_DELETED_USERS)->get(); } return $users->lists('fullname', 'id')->all(); }
/** * Fetch a user by column * * @param string $field * @param int|string|bool $value * * @return Model\User */ public function fetchUserBy($field, $value) { return Model\User::where($field, '=', $value)->first(); }
/** * Stage two: * - Collect details for admin user * - Create the admin user * * @return void */ protected function stageTwo() { $this->section('Setting up the admin account:'); $this->askQuestions(['adminEmail' => 'Email address', 'adminFirstName' => 'First Name', 'adminLastName' => 'Last Name', 'adminPass' => 'Password']); Model\User::updateOrCreate(['email' => $this->data['adminEmail']], ['email' => $this->data['adminEmail'], 'firstname' => $this->data['adminFirstName'], 'lastname' => $this->data['adminLastName'], 'password' => \Hash::make($this->data['adminPass']), 'deleted' => Model\User::NOT_DELETED_USERS, 'role_id' => 4, 'language' => 'en']); $this->info('Admin account created successfully.'); }
/** * @param int $deleted * * @return int */ public static function countUsers($deleted = User::NOT_DELETED_USERS) { return User::where('deleted', '=', $deleted)->count(); }
/** * Delete an existing user * * @param User $user * * @return \Illuminate\Http\RedirectResponse */ public function getDelete(User $user) { $user->delete(); return redirect('administration/users')->with('notice', trans('tinyissue.user_deleted')); }
/** * Show general application stats * * @param Tag $tag * @param Project $project * @param User $user * * @return \Illuminate\View\View */ public function getIndex(Tag $tag, Project $project, User $user) { return view('administration.index', ['users' => $user->countUsers(), 'active_projects' => $project->countOpenProjects(), 'archived_projects' => $project->countArchivedProjects(), 'open_issues' => $project->countOpenIssues(), 'closed_issues' => $project->countClosedIssues(), 'projects' => $this->auth->user()->projects()->get(), 'tags' => $tag->count()]); }