/** * Shows the dashboard view. * * @return \Illuminate\View\View */ public function indexAction() { $projects = Project::get(); $issues = $this->getIssues(); $subscribers = $this->getSubscribers(); return View::make('dashboard.index')->withPageTitle(trans('dashboard.dashboard'))->withProjects($projects)->withIssues($issues)->withSubscribers($subscribers); }
/** * 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()); }
/** * 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; }
/** * Seed the projects table. * * @return void */ protected function seedProjects() { $defaultProjects = [['name' => 'API', 'description' => 'Used by third-parties to connect to us', 'status' => 1, 'order' => 0, 'team_id' => 0, 'slug' => 'Gitamin'], ['name' => 'Documentation', 'description' => 'Kindly powered by Readme.io', 'status' => 1, 'order' => 0, 'team_id' => 1, 'slug' => 'Baidu'], ['name' => 'Website', 'description' => '', 'status' => 1, 'order' => 0, 'team_id' => 1, 'slug' => 'Alibaba'], ['name' => 'Blog', 'description' => 'The Gitamin Blog.', 'status' => 1, 'order' => 0, 'team_id' => 1, 'slug' => 'Tencent']]; Project::truncate(); foreach ($defaultProjects as $project) { Project::create($project); } }
/** * Seed the projects table. */ protected function seedProjects() { $defaultProjects = [['name' => 'API', 'description' => 'Used by third-parties to connect to us', 'visibility_level' => 0, 'owner_id' => 1, 'creator_id' => 1, 'path' => 'api'], ['name' => 'Documentation', 'description' => 'Kindly powered by Readme.io', 'visibility_level' => 1, 'owner_id' => 2, 'creator_id' => 1, 'path' => 'doc'], ['name' => 'Website', 'description' => 'Tencent Holdings Limited is a Chinese investment holding company', 'visibility_level' => 1, 'owner_id' => 3, 'creator_id' => 1, 'path' => 'website'], ['name' => 'Blog', 'description' => 'The Gitamin Blog.', 'visibility_level' => 1, 'owner_id' => 4, 'creator_id' => 1, 'path' => 'blog']]; Project::truncate(); foreach ($defaultProjects as $project) { Project::create($project); } }
/** * 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')); }
/** * Updates a projects ordering. * * @return array */ public function postUpdateProjectOrder() { $projectData = Request::get('ids'); foreach ($projectData as $order => $projectId) { // Ordering should be 1-based, data comes in 0-based Project::find($projectId)->update(['order' => $order + 1]); } return $projectData; }
/** * Shows the dashboard view. * * @return \Illuminate\View\View */ public function showDashboard() { $projects = Project::orderBy('order')->get(); //var_dump($projects); //$projects = []; $issues = $this->getIssues(); $subscribers = $this->getSubscribers(); return View::make('dashboard.index')->withPageTitle(trans('dashboard.dashboard'))->withProjects($projects)->withIssues($issues)->withSubscribers($subscribers); }
/** * Display the default view of dashboard. * * @return \Illuminate\Http\Response */ public function indexAction(AdminRequest $request) { $this->subMenu['overview']['active'] = true; Session::flash('redirect_to', $this->subMenu['general']['url']); $projects = Project::orderBy('created_at')->get(); $projects = Project::get(); $issues = []; $subscribers = []; return View::make('admin.index')->withPageTitle(trans('admin.admin'))->withProjects($projects)->withIssues($issues)->withSubscribers($subscribers)->withSubMenu($this->subMenu); }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function createAction($owner_path, $project_path) { $project = Project::findByPath($owner_path, $project_path); $commentData = Request::get('comment'); try { $commentData['author_id'] = Auth::user()->id; $commentData['project_id'] = $project->id; $comment = $this->dispatchFromArray(AddCommentCommand::class, $commentData); } catch (ValidationException $e) { return Redirect::route('projects.issue_show', ['owner' => $owner_path, 'project' => $project_path, 'issue' => $commentData['target_id']])->withInput(Request::all())->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.issues.new.failure')))->withErrors($e->getMessageBag()); } return Redirect::route('projects.issue_show', ['owner' => $owner_path, 'project' => $project_path, 'issue' => $commentData['target_id']])->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.issues.new.success'))); }
/** * 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(); }); }
/** * Update an existing project. * * @param \Gitamin\Models\Project $project * * @return \Illuminate\Http\JsonResponse */ public function putProject(Request $request, Project $project) { try { $this->dispatch(new UpdateProjectCommand($project, $request->get('name'), $request->get('description'), $request->get('visibility_level'), $request->get('path'), $request->get('creator_id'), $request->get('owner_id'))); } catch (QueryException $e) { throw new BadRequestHttpException(); } if ($request->has('tags')) { $tags = preg_split('/ ?, ?/', $request->get('tags')); // For every tag, do we need to create it? $projectTags = array_map(function ($taggable) use($project) { return Tag::firstOrCreate(['name' => $taggable])->id; }, $tags); $project->tags()->sync($projectTags); } return $this->item($project); }
/** * Update an existing project. * * @param \Gitamin\Models\Project $project * * @return \Illuminate\Http\JsonResponse */ public function putProject(Project $project) { try { $this->dispatch(new UpdateProjectCommand($project, Binput::get('name'), Binput::get('description'), Binput::get('status'), Binput::get('slug'), Binput::get('order'), Binput::get('team_id'), (bool) Binput::get('enabled', true))); } catch (QueryException $e) { throw new BadRequestHttpException(); } if (Binput::has('tags')) { $tags = preg_split('/ ?, ?/', Binput::get('tags')); // For every tag, do we need to create it? $projectTags = array_map(function ($taggable) use($project) { return Tag::firstOrCreate(['name' => $taggable])->id; }, $tags); $project->tags()->sync($projectTags); } return $this->item($project); }
public function updateAction($owner_path, $project_path, Issue $issue) { $project = Project::findByPath($owner_path, $project_path); $issueData = Request::get('issue'); try { $issueData['author_id'] = Auth::user()->id; $issueData['project_id'] = $project->id; $issueData['issue'] = $issue; $issue = $this->dispatchFromArray(UpdateIssueCommand::class, $issueData); } catch (ValidationException $e) { return Redirect::route('projects.issue_edit', ['owner' => $owner_path, 'project' => $project_path, 'issue' => $issue->id])->withInput(Request::all())->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.issues.edit.failure')))->withErrors($e->getMessageBag()); } //Do nothing /* if ($issue->project) { $issue->project->update(['status' => Request::get('project_status')]); } */ return Redirect::route('projects.issue_edit', ['owner' => $owner_path, 'project' => $project_path, 'issue' => $issue->id])->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.issues.edit.success'))); }
/** * 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); }
/** * Returns the projects a user is authorized to access. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function authorized_projects() { $projectIds = ProjectMember::where('user_id', '=', $this->id)->where('target_type', '=', 'Project')->lists('target_id')->toArray(); return Project::whereIn('id', $projectIds)->get(); }
public function index() { $projects = Project::all(); return View::make('index')->withProjects($projects); }
/** * 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); }
/** * Update the specified resource in storage. * * @param string $owner_path * @param string $project_path * * @return \Illuminate\Http\Response */ public function updateAction($owner_path, $project_path) { $projectData = Request::get('project'); $tags = array_pull($projectData, 'tags'); $project = Project::find($projectData['id']); $projectData['namespace_id'] = $project->namespace_id; try { $projectData['project'] = $project; $projectData['creator_id'] = Auth::user()->id; $projectData['owner_id'] = $project->owner->id; $project = $this->dispatchFromArray(UpdateProjectCommand::class, $projectData); } catch (ValidationException $e) { return Redirect::route('projects.project_edit', ['owner' => $project->owner_path, 'project' => $project->path])->withInput(Request::all())->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.projects.edit.failure')))->withErrors($e->getMessageBag()); } // The project was updated successfully, so now let's deal with the tags. $tags = preg_split('/ ?, ?/', $tags); return Redirect::route('projects.project_edit', ['owner' => $project->owner_path, 'project' => $project->path])->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.projects.edit.success'))); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function indexAction($namespace, $project_path) { $project = Project::findByPath($namespace, $project_path); return View::make('projects.pulse.index')->withProject($project)->withWikis([])->withActiveItem($this->active_item)->withPageTitle(sprintf('%s - %s', trans('dashboard.issues.issues'), $project->name)); }
/** * 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()); }
/** * 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()); }
public function starred() { $projects = Project::orderBy('created_at')->get(); $this->subMenu['starred']['active'] = true; return View::make('dashboard.projects.index')->withPageTitle(trans_choice('dashboard.projects.projects', 2) . ' - ' . trans('dashboard.dashboard'))->withProjects($projects)->withSubMenu($this->subMenu); }
/** * 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()); }
/** * Handle the add project command. * * @param \Gitamin\Commands\Project\AddProjectCommand $command * * @return \Gitamin\Models\Project */ public function handle(AddProjectCommand $command) { $project = Project::create($this->filter($command)); event(new ProjectWasAddedEvent($project)); return $project; }