/** * Bind data to the view. * * @param \Illuminate\Contracts\View\View $view */ public function compose(View $view) { $view->withIssueCount(Issue::all()->count()); $view->withProjectCount(Project::all()->count()); $view->withGroupCount(Group::count()); $view->withMomentCount(Moment::all()->count()); }
/** * Handle the add isssue command. * * @param \Gitamin\Commands\Issue\AddIssueCommand $command * * @return \Gitamin\Models\Issue */ public function handle(AddIssueCommand $command) { $data = ['author_id' => $command->authorId, 'project_id' => $command->projectId, 'title' => $command->title, 'description' => $command->description, 'created_at' => Carbon::now()->toDateTimeString()]; // Create the issue $issue = Issue::create($data); return $issue; }
/** * Get all issues. * * @param \Symfony\Component\HttpFoundation\Request $request * @param \Illuminate\Contracts\Auth\Guard $auth * * @return \Illuminate\Http\JsonResponse */ public function getIssues(Request $request, Guard $auth) { //$issuePosition = $auth->check() ? 0 : 1; $issuePosition = $auth->check() ? 0 : -1; $issues = Issue::where('position', '>=', $issuePosition)->paginate($request->get('per_page', 20)); return $this->paginator($issues, $request); }
/** * Shows the issues view. * * @return \Illuminate\View\View */ public function indexAction() { $state = Request::get('state'); // Issue & Issue Project list. $usedIssueProjects = Issue::where('project_id', '>', 0)->where('state', '=', $state)->groupBy('project_id')->lists('project_id'); $issueProjects = Project::whereIn('id', $usedIssueProjects)->get(); return View::make('dashboard.issues.index')->withIssueProjects($issueProjects)->withPageTitle(trans('dashboard.issues.issues') . ' - ' . trans('dashboard.dashboard')); }
/** * 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(); }); }
/** * Generates a feed of all issues. * * @param \Gitamin\Models\Owner|null $owner * @param bool $isRss * * @return \Illuminate\Http\Response */ private function feedAction(Owner &$owner, $isRss) { if ($owner->exists) { $owner->projects->map(function ($project) { $project->issues()->visible()->orderBy('created_at', 'desc')->get()->map(function ($issue) use($isRss) { $this->feedAddItem($issue, $isRss); }); }); } else { Issue::visible()->orderBy('created_at', 'desc')->get()->map(function ($issue) use($isRss) { $this->feedAddItem($issue, $isRss); }); } return $this->feed->render($isRss ? 'rss' : 'atom'); }
/** * Handle the report issue command. * * @param \Gitamin\Commands\Issue\AddIssueCommand $command * * @return \Gitamin\Models\Issue */ public function handle(AddIssueCommand $command) { $data = ['title' => $command->title, 'description' => $command->description]; // Link with the user. if ($command->author_id) { $data['author_id'] = $command->author_id; } // Link with the project. if ($command->project_id) { $data['project_id'] = $command->project_id; } // Create the issue $issue = Issue::create($data); event(new IssueWasAddedEvent($issue)); return $issue; }
/** * Displays the explore page. * * @return \Illuminate\View\View */ public function showIndex() { $today = Date::now(); $startDate = Date::now(); // Check if we have another starting date if (Binput::has('start_date')) { try { // If date provided is valid $oldDate = Date::createFromFormat('Y-m-d', Binput::get('start_date')); // If trying to get a future date fallback to today if ($today->gt($oldDate)) { $startDate = $oldDate; } } catch (Exception $e) { // Fallback to today } } $daysToShow = Setting::get('app_issue_days', 0) - 1; if ($daysToShow < 0) { $daysToShow = 0; $issueDays = []; } else { $issueDays = range(0, $daysToShow); } $dateTimeZone = Setting::get('app_timezone'); $issueVisiblity = Auth::check() ? 0 : 1; $allIssues = Issue::where('visible', '>=', $issueVisiblity)->whereBetween('created_at', [$startDate->copy()->subDays($daysToShow)->format('Y-m-d') . ' 00:00:00', $startDate->format('Y-m-d') . ' 23:59:59'])->orderBy('scheduled_at', 'desc')->orderBy('created_at', 'desc')->get()->groupBy(function (Issue $issue) use($dateTimeZone) { // If it's scheduled, get the scheduled at date. if ($issue->is_scheduled) { return (new Date($issue->scheduled_at))->setTimezone($dateTimeZone)->toDateString(); } return (new Date($issue->created_at))->setTimezone($dateTimeZone)->toDateString(); }); // Add in days that have no issues foreach ($issueDays as $i) { $date = (new Date($startDate))->setTimezone($dateTimeZone)->subDays($i); if (!isset($allIssues[$date->toDateString()])) { $allIssues[$date->toDateString()] = []; } } // Sort the array so it takes into account the added days $allIssues = $allIssues->sortBy(function ($value, $key) { return strtotime($key); }, SORT_REGULAR, true)->all(); return View::make('index')->withDaysToShow($daysToShow)->withAllIssues($allIssues)->withCanPageForward((bool) $today->gt($startDate))->withCanPageBackward(Issue::where('created_at', '<', $startDate->format('Y-m-d'))->count() > 0)->withPreviousDate($startDate->copy()->subDays($daysToShow)->toDateString())->withNextDate($startDate->copy()->addDays($daysToShow)->toDateString()); }
/** * Fetches all of the issues over the last 30 days. * * @return \Illuminate\Support\Collection */ protected function getIssues() { $allIssues = Issue::whereBetween('created_at', [$this->startDate->copy()->subDays(30)->format('Y-m-d') . ' 00:00:00', $this->startDate->format('Y-m-d') . ' 23:59:59'])->orderBy('created_at', 'desc')->get()->groupBy(function (Issue $issue) { return (new Date($issue->created_at))->setTimezone($this->dateTimeZone)->toDateString(); }); // Add in days that have no issues foreach (range(0, 30) as $i) { $date = (new Date($this->startDate))->setTimezone($this->dateTimeZone)->subDays($i); if (!isset($allIssues[$date->toDateString()])) { $allIssues[$date->toDateString()] = []; } } // Sort the array so it takes into account the added days $allIssues = $allIssues->sortBy(function ($value, $key) { return strtotime($key); }, SORT_REGULAR, false); return $allIssues; }
/** * Displays the explore page. * * @return \Illuminate\View\View */ public function indexAction() { $this->subMenu['explore']['active'] = true; $today = Date::now(); $startDate = Date::now(); // Check if we have another starting date if (Request::has('start_date')) { try { // If date provided is valid $oldDate = Date::createFromFormat('Y-m-d', Request::get('start_date')); // If trying to get a future date fallback to today if ($today->gt($oldDate)) { $startDate = $oldDate; } } catch (Exception $e) { // Fallback to today } } $daysToShow = Setting::get('app_issue_days', 0) - 1; if ($daysToShow < 0) { $daysToShow = 0; $issueDays = []; } else { $issueDays = range(0, $daysToShow); } $dateTimeZone = Setting::get('app_timezone'); $allIssues = Issue::whereBetween('created_at', [$startDate->copy()->subDays($daysToShow)->format('Y-m-d') . ' 00:00:00', $startDate->format('Y-m-d') . ' 23:59:59'])->orderBy('created_at', 'desc')->get()->groupBy(function (Issue $issue) use($dateTimeZone) { return (new Date($issue->created_at))->setTimezone($dateTimeZone)->toDateString(); }); // Add in days that have no issues foreach ($issueDays as $i) { $date = (new Date($startDate))->setTimezone($dateTimeZone)->subDays($i); if (!isset($allIssues[$date->toDateString()])) { $allIssues[$date->toDateString()] = []; } } // Sort the array so it takes into account the added days $allIssues = $allIssues->sortBy(function ($value, $key) { return strtotime($key); }, SORT_REGULAR, true)->all(); return View::make('explore.index')->withPageTitle(trans('dashboard.explore'))->withProjects([])->withSubMenu($this->subMenu)->withDaysToShow($daysToShow)->withAllIssues($allIssues)->withCanPageForward((bool) $today->gt($startDate))->withCanPageBackward(Issue::where('created_at', '<', $startDate->format('Y-m-d'))->count() > 0)->withPreviousDate($startDate->copy()->subDays($daysToShow)->toDateString())->withNextDate($startDate->copy()->addDays($daysToShow)->toDateString()); }
/** * 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); }
/** * Handle the report issue command. * * @param \Gitamin\Commands\Issue\AddIssueCommand $command * * @return \Gitamin\Models\Issue */ public function handle(AddIssueCommand $command) { $data = ['name' => $command->name, 'status' => $command->status, 'message' => $command->message, 'visible' => $command->visible]; // Link with the user. if ($command->user_id) { $data['user_id'] = $command->user_id; } // Link with the project. if ($command->project_id) { $data['project_id'] = $command->project_id; } // The issue occurred at a different time. if ($command->issue_date) { $issueDate = $this->dates->createNormalized('d/m/Y H:i', $command->issue_date); $data['created_at'] = $issueDate; $data['updated_at'] = $issueDate; } // Create the issue $issue = Issue::create($data); $issue->notify = (bool) $command->notify; event(new IssueWasAddedEvent($issue)); return $issue; }
/** * Bind data to the view. * * @param \Illuminate\Contracts\View\View $view * * @return void */ public function compose(View $view) { $view->withIssueCount(Issue::all()->count()); $view->withProjectCount(Project::all()->count()); $view->withGroupCount(Group::IsGroup()->Mine()->count()); }
/** * Seed the issues table. * * @return void */ protected function seedIssues() { $defaultIssues = [['name' => 'Awesome', 'message' => ':+1: We totally nailed the fix.', 'status' => 4, 'project_id' => 0, 'scheduled_at' => null, 'visible' => 1], ['name' => 'Monitoring the fix', 'message' => ":ship: We've deployed a fix.", 'status' => 3, 'project_id' => 0, 'scheduled_at' => null, 'visible' => 1], ['name' => 'Update', 'message' => "We've identified the problem. Our engineers are currently looking at it.", 'status' => 2, 'project_id' => 0, 'scheduled_at' => null, 'visible' => 1], ['name' => 'Test Issue', 'message' => 'Something went wrong, with something or another.', 'status' => 1, 'project_id' => 0, 'scheduled_at' => null, 'visible' => 1], ['name' => 'Investigating the API', 'message' => ':zap: We\'ve seen high response times from our API. It looks to be fixing itself as time goes on.', 'status' => 1, 'project_id' => 1, 'scheduled_at' => null, 'visible' => 1]]; Issue::truncate(); foreach ($defaultIssues as $issue) { Issue::create($issue); } }
/** * Bind data to the view. * * @param \Illuminate\Contracts\View\View $view * * @return void */ public function compose(View $view) { $view->withIssueCount(Issue::all()->count()); $view->withProjectCount(Project::all()->count()); $view->withProjectTeamCount(ProjectTeam::all()->count()); }
/** * Seed the issues table. */ protected function seedIssues() { $defaultIssues = [['title' => 'Awesome', 'description' => ':+1: We totally nailed the fix.', 'author_id' => 1, 'project_id' => 1], ['title' => 'Monitoring the fix', 'description' => ":ship: We've deployed a fix.", 'author_id' => 3, 'project_id' => 2], ['title' => 'Update', 'description' => "We've identified the problem. Our engineers are currently looking at it.", 'author_id' => 2, 'project_id' => 1], ['title' => 'Test Issue', 'description' => 'Something went wrong, with something or another.', 'author_id' => 1, 'project_id' => 2], ['title' => 'Investigating the API', 'description' => ':zap: We\'ve seen high response times from our API. It looks to be fixing itself as time goes on.', 'author_id' => 1, 'project_id' => 3]]; foreach ($defaultIssues as $issue) { Issue::create($issue); } }
/** * Shows the issues view. * * @return \Illuminate\View\View */ public function showIssues() { $issues = Issue::orderBy('created_at', 'desc')->get(); return View::make('dashboard.issues.index')->withPageTitle(trans('dashboard.issues.issues') . ' - ' . trans('dashboard.dashboard'))->withIssues($issues); }
/** * Generates an Atom feed of all issues. * * @param \Gitamin\Models\ProjectTeam|null $namespace * * @return \Illuminate\Http\Response */ public function feedAction(ProjectNamespace $namespace = null) { if ($namespace->exists) { $namespace->projects->map(function ($project) { $project->issues()->visible()->orderBy('created_at', 'desc')->get()->map(function ($issue) { $this->feedAddItem($issue); }); }); } else { Issue::visible()->orderBy('created_at', 'desc')->get()->map(function ($issue) { $this->feedAddItem($issue); }); } return $this->feed->render($this->isRss ? 'rss' : 'atom'); }
/** * Get all issues. * * @param \Symfony\Component\HttpFoundation\Request $request * @param \Illuminate\Contracts\Auth\Guard $auth * * @return \Illuminate\Http\JsonResponse */ public function getIssues(Request $request, Guard $auth) { $issueVisiblity = $auth->check() ? 0 : 1; $issues = Issue::where('visible', '>=', $issueVisiblity)->paginate(Binput::get('per_page', 20)); return $this->paginator($issues, $request); }