/** * 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; }
/** * 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'))); }