/** * Find project under this owner by path, or throw an exception. * * @param string $path * @param string[] $columns * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException * * @return \Gitamin\Models\User */ public function project($path, $columns = ['*']) { $project = Project::where('owner_id', '=', $this->id)->where('path', '=', $path)->first($columns); if (!$project) { throw new ModelNotFoundException(); } return $project; }
/** * Register model bindings. * * @return void */ protected function registerBindings() { $this->app->router->model('owner', Owner::class, function ($slug) { return Owner::where('slug', $slug)->firstOrFail(); }); $this->app->router->bind('project', function ($slug, $route) { $owner = $route->getParameter('owner'); return Project::where(['owner_id' => $owner->id, 'slug' => $slug])->firstOrFail(); }); $this->app->router->bind('issue', function ($iid, $route) { $project = $route->getParameter('project'); return Issue::where(['project_id' => $project->id, 'iid' => $iid])->firstOrFail(); }); }
/** * Index page view composer. * * @param \Illuminate\Contracts\View\View $view * * @return void */ public function compose(View $view) { // Default data $withData = ['systemStatus' => 'info', 'systemMessage' => trans('gitamin.service.bad'), 'favicon' => 'favicon-high-alert']; if (Project::notVisibilityLevel(1)->count() === 0) { // If all our projects are ok, do we have any non-fixed issues? $issues = Issue::orderBy('created_at', 'desc')->get(); $issueCount = $issues->count(); if ($issueCount === 0 || $issueCount >= 1 && (int) $issues->first()->visibility_level === 4) { $withData = ['systemStatus' => 'success', 'systemMessage' => trans('gitamin.service.good'), 'favicon' => 'favicon']; } } else { if (Project::whereIn('visibility_level', [2, 3])->count() > 0) { $withData['favicon'] = 'favicon-medium-alert'; } } // Project & Project Team lists. $usedProjectTeams = Project::where('namespace_id', '>', 0)->groupBy('namespace_id')->lists('namespace_id'); $projectTeams = ProjectNamespace::whereIn('id', $usedProjectTeams)->get(); $unteamedProjects = Project::where('namespace_id', 0)->orderBy('created_at')->get(); $view->with($withData)->withProjectTeams($projectTeams)->withUnteamedProjects($unteamedProjects); }
/** * Shows the user profile view. * * @return \Illuminate\View\View */ protected function showUser(User &$user) { $usedProjects = Project::where('owner_id', '=', $user->id)->lists('id')->toArray(); $moments = Moment::whereIn('project_id', $usedProjects)->get(); return View::make('profiles.show')->withPageTitle($user->name)->withUser($user)->withMoments($moments); }
/** * Shows the edit issue view. * * @param \Gitamin\Models\Issue $issue * * @return \Illuminate\View\View */ public function showEditIssueAction(Issue $issue) { return View::make('dashboard.issues.edit')->withPageTitle(trans('dashboard.issues.edit.title') . ' - ' . trans('dashboard.dashboard'))->withIssue($issue)->withProjectsInTeams(ProjectTeam::with('projects')->get())->withProjectsOutTeams(Project::where('team_id', 0)->get()); }