コード例 #1
0
 /**
  * Validate the input and store the ProjectPhaseDocumentComment in the database.
  *
  * @param \Illuminate\Http\Request $request
  * @param int $projectId
  * @param int $projectPhaseId
  * @param int $projectPhaseDocumentId
  *
  * @return Response
  */
 public function store(Request $request, $projectId, $projectPhaseId, $projectPhaseDocumentId)
 {
     $projectPhaseDocument = ProjectPhaseDocument::where('id', '=', $projectPhaseDocumentId)->where('project_phase_id', '=', $projectPhaseId)->firstOrFail();
     $this->validate($request, $this->createProjectPhasePhaseDocumentCommentRules);
     $projectPhaseDocumentComment = ProjectPhaseDocumentComment::create(['project_phase_document_id' => $projectPhaseDocument->id, 'content' => $request->input('content')]);
     if (!isset($projectPhaseDocumentComment)) {
         abort(503);
     }
     return redirect()->route('project.phase.document.show', ['project' => $projectId, 'phase' => $projectPhaseId, 'document' => $projectPhaseDocumentId]);
 }
コード例 #2
0
 /**
  * Test that a ProjectPhaseDocument can be edited via form and a history element was created.
  */
 public function testEditForm()
 {
     $admin = $this->createSuperuser();
     $this->be($admin);
     $project = $this->createProject();
     $projectPhase = $this->createProjectPhase(1, $project);
     $projectPhaseDocument = $this->createProjectPhaseDocument($projectPhase);
     $originalTitle = $projectPhaseDocument->title;
     $this->call('GET', route('project.phase.document.edit', ['project' => $project->id, 'phase' => $projectPhase->id, 'document' => $projectPhaseDocument->id]));
     $this->assertResponseOk();
     $this->call('PUT', route('project.phase.document.update', ['project' => $project->id, 'phase' => $projectPhase->id, 'document' => $projectPhaseDocument->id]), ['title' => 'My Test ProjectPhaseDocument Update', 'content' => 'My ProjectPhaseDocumentContentUpdate', 'type' => 'published', '_token' => Session::token()]);
     $this->assertRedirectedToRoute('project.phase.document.show', ['project' => $project->id, 'phase' => $projectPhase->id, 'document' => $projectPhaseDocument->id]);
     $projectPhaseDocument = ProjectPhaseDocument::find($projectPhaseDocument->id);
     $this->assertNotNull($projectPhaseDocument);
     $this->assertEquals('My Test ProjectPhaseDocument Update', $projectPhaseDocument->title);
     $projectPhaseDocumentHistory = ProjectPhaseDocument::where('parent_project_phase_document_id', '=', $projectPhaseDocument->id)->where('type', '=', 'history')->first();
     $this->assertNotNull($projectPhaseDocumentHistory);
     $this->assertEquals($originalTitle, $projectPhaseDocumentHistory->title);
 }
コード例 #3
0
 /**
  * Compare two versions of a ProjectPhaseDocument.
  *
  * @param Request $request
  * @param int $projectId
  * @param int $projectPhaseId
  * @param int $projectPhaseDocumentId
  *
  * @return Response
  */
 public function compare(Request $request, $projectId, $projectPhaseId, $projectPhaseDocumentId)
 {
     $projectPhaseDocument = ProjectPhaseDocument::where('id', '=', $projectPhaseDocumentId)->where('project_phase_id', '=', $projectPhaseId)->with(['history', 'phase', 'phase.project'])->firstOrFail();
     $old = ProjectPhaseDocument::where('id', '=', $request->input('old'))->where(function (\Illuminate\Database\Eloquent\Builder $query) use($projectPhaseDocument) {
         $query->where('parent_project_phase_document_id', '=', $projectPhaseDocument->id)->orWhere('id', '=', $projectPhaseDocument->id);
     })->firstOrFail();
     $new = ProjectPhaseDocument::where('id', '=', $request->input('new'))->where(function (\Illuminate\Database\Eloquent\Builder $query) use($projectPhaseDocument) {
         $query->where('parent_project_phase_document_id', '=', $projectPhaseDocument->id)->orWhere('id', '=', $projectPhaseDocument->id);
     })->firstOrFail();
     if (!isset($old) || !isset($new)) {
         abort(404);
     }
     $diff = new \Diff(explode("\n", $old->content), explode("\n", $new->content));
     $renderer = new \VisualAppeal\Connect\Extensions\DiffRenderer();
     $renderer->oldTitle = $old->created_at->timezone(\Sentry::getUser()->timezone)->format(\Config::get('app.format.dateTime'));
     $renderer->newTitle = $new->created_at->timezone(\Sentry::getUser()->timezone)->format(\Config::get('app.format.dateTime'));
     $render = $diff->render($renderer);
     return view('project.phase.document.compare', ['project' => $projectPhaseDocument->phase->project, 'projectPhase' => $projectPhaseDocument->phase, 'projectPhaseDocument' => $projectPhaseDocument, 'render' => $render]);
 }