/**
  * Validate the input and store the ProjectPhase in the database.
  *
  * @param \Illuminate\Http\Request $request
  * @param int $projectId
  *
  * @return Response
  */
 public function store(Request $request, $projectId)
 {
     $project = Project::where('id', '=', $projectId)->with(['phases'])->firstOrFail();
     $this->validate($request, $this->createProjectPhasePhaseRules);
     $number = $request->input('number') + 1;
     $startedAt = $request->input('started_at') ? \Carbon\Carbon::createFromTimestamp(strtotime($request->input('started_at'))) : null;
     $completedAt = $request->input('completed_at') ? \Carbon\Carbon::createFromTimestamp(strtotime($request->input('completed_at'))) : null;
     $planedStartedAt = $request->input('planed_started_at') ? \Carbon\Carbon::createFromTimestamp(strtotime($request->input('planed_started_at'))) : null;
     $planedCompletedAt = $request->input('planed_completed_at') ? \Carbon\Carbon::createFromTimestamp(strtotime($request->input('planed_completed_at'))) : null;
     $projectPhase = ProjectPhase::create(['project_id' => $project->id, 'title' => $request->input('title'), 'description' => $request->input('description'), 'number' => $number, 'started_at' => $startedAt, 'completed_at' => $completedAt, 'planed_started_at' => $planedStartedAt, 'planed_completed_at' => $planedCompletedAt]);
     if (!isset($projectPhase)) {
         abort(503);
     }
     // Rearange positions
     \DB::table('projects_phases')->where('project_id', '=', $projectId)->where('id', '!=', $projectPhase->id)->where('number', '>=', $number)->increment('number');
     return redirect()->route('project.phase.show', ['project' => $project->id, 'phase' => $projectPhase->id]);
 }
예제 #2
0
 /**
  * Displays the Project details.
  *
  * @return Response
  */
 public function show($id)
 {
     $project = Project::where('id', '=', $id)->with(['profiles', 'phases', 'departments', 'clients'])->firstOrFail();
     return view('project.show', ['project' => $project]);
 }