示例#1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // ID 1
     \VisualAppeal\Connect\Project::create(['company_id' => 2, 'title' => 'New software', 'website' => 'http://ibm.com', 'repository' => 'https://github.com/IBM/ibm.github.io', 'bugtracker' => 'https://github.com/IBM/ibm.github.io/issues', 'started_at' => '2014-10-10 14:12:56', 'completed_at' => '2015-03-09 21:51:01']);
     // ID 2
     \VisualAppeal\Connect\Project::create(['company_id' => 2, 'title' => 'Javascript Christmas Tree', 'started_at' => '2014-12-24 12:13:14']);
     // ID 1
     \VisualAppeal\Connect\ProjectPhase::create(['project_id' => 2, 'title' => 'Requirements Specification', 'number' => 1, 'started_at' => '2014-12-25 12:13:14', 'completed_at' => '2014-12-26 12:13:14']);
     // ID 2
     \VisualAppeal\Connect\ProjectPhase::create(['project_id' => 2, 'title' => 'Functional Specification', 'number' => 2, 'started_at' => '2014-12-27 12:13:14', 'completed_at' => '2014-12-28 12:13:14']);
     // ID 3
     \VisualAppeal\Connect\ProjectPhase::create(['project_id' => 2, 'title' => 'Contract', 'number' => 3, 'started_at' => '2014-12-29 12:13:14', 'planed_completed_at' => date('Y-m-d H:i:s', time() + 3600 * 24)]);
     // ID 4
     \VisualAppeal\Connect\ProjectPhase::create(['project_id' => 2, 'number' => 4, 'title' => 'Implementation']);
     // ID 5
     \VisualAppeal\Connect\ProjectPhase::create(['project_id' => 2, 'number' => 5, 'title' => 'Testing']);
     // ID 1
     \VisualAppeal\Connect\ProjectCompanyDepartment::create(['project_id' => 2, 'company_department_id' => 1]);
     // ID 2
     \VisualAppeal\Connect\ProjectCompanyDepartment::create(['project_id' => 2, 'company_department_id' => 2]);
     // ID 1
     \VisualAppeal\Connect\ProjectClient::create(['project_id' => 2, 'client_id' => 1]);
     // ID 1
     \VisualAppeal\Connect\ProjectPhaseDocument::create(['project_phase_id' => 3, 'title' => 'Contract', 'content' => "## Contract\n\nThat is the contract.", 'created_at' => date('Y-m-d H:i:s', time() - 3600 * 7.1), 'updated_at' => date('Y-m-d H:i:s', time() - 3600 * 7.1)]);
     // ID 2
     \VisualAppeal\Connect\ProjectPhaseDocument::create(['project_phase_id' => 3, 'parent_project_phase_document_id' => 1, 'title' => 'Contract', 'content' => "## Contract\n\nThat is the contract.\n\n### Payment\n\nPay now!", 'type' => 'history', 'created_at' => date('Y-m-d H:i:s', time() - 3600 * 3.8), 'updated_at' => date('Y-m-d H:i:s', time() - 3600 * 3.8)]);
     // ID 3
     \VisualAppeal\Connect\ProjectPhaseDocument::create(['project_phase_id' => 3, 'parent_project_phase_document_id' => 1, 'title' => 'Contract', 'content' => "## Contract\n\nThat is the contract.\n\n### Payment\n\nPay later...", 'type' => 'history', 'created_at' => date('Y-m-d H:i:s', time() - 3600), 'updated_at' => date('Y-m-d H:i:s', time() - 3600)]);
     // ID 1
     \VisualAppeal\Connect\ProjectPhaseDocumentComment::create(['project_phase_document_id' => 1, 'content' => 'I *love* the contract!', 'created_at' => date('Y-m-d H:i:s', time() - 3600), 'updated_at' => date('Y-m-d H:i:s', time() - 3600)]);
     // ID 2
     \VisualAppeal\Connect\ProjectPhaseDocumentComment::create(['project_phase_document_id' => 1, 'content' => 'Me too', 'created_at' => date('Y-m-d H:i:s', time() - 1800), 'updated_at' => date('Y-m-d H:i:s', time() - 1600)]);
 }
 /**
  * Validate the input and store the company department in the database.
  *
  * @param \Illuminate\Http\Request $request
  * @param int $projectId
  *
  * @return Response
  */
 public function store(Request $request, $projectId)
 {
     $project = Project::findOrFail($projectId);
     $this->validate($request, $this->createProjectCompanyDepartmentRules);
     $department = ProjectCompanyDepartment::create(['project_id' => $project->id, 'company_department_id' => $request->input('company_department_id')]);
     if (!isset($department)) {
         abort(503);
     }
     return redirect()->route('project.show', ['project' => $project->id]);
 }
示例#3
0
 /**
  * Test that a Project can be deleted via interface.
  */
 public function testDeleteForm()
 {
     $admin = $this->createSuperuser();
     $this->be($admin);
     $project = $this->createProject();
     $this->call('GET', route('project.show', ['project' => $project->id]));
     $this->assertResponseOk();
     $response = $this->call('DELETE', route('project.destroy', ['project' => $project->id]), ['_token' => Session::token()]);
     $this->assertRedirectedToRoute('project.index');
     $project = \VisualAppeal\Connect\Project::find(1);
     $this->assertNull($project);
 }
 /**
  * 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]);
 }
 /**
  * Delete profile field.
  *
  * @param int $projectId
  * @param int $profileId
  *
  * @return Response
  */
 public function destroy($projectId, $profileId)
 {
     $project = Project::findOrFail($projectId);
     $profile = ProjectProfile::findOrFail($profileId);
     $profile->delete();
     return redirect()->route('project.show', ['project' => $project->id]);
 }
 /**
  * Register events.
  *
  * @param \Illuminate\Contracts\Events\Dispatcher $events
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     parent::boot($events);
     /**
      * Users
      */
     // Create client with user
     User::created(function (User $user) {
         // Save ID of user who created the client
         $client = new Client();
         if (\Sentry::check()) {
             $client->user_id = \Sentry::getUser()->id;
         }
         $client->save();
         // Save ID of the client in the user model
         $user->client_id = $client->id;
         $user->save();
     });
     // Client about to be created
     Client::creating(function (Client $client) {
         if (\Sentry::check()) {
             $client->user_id = \Sentry::getUser()->id;
         }
     });
     // ClientProfile about to be created
     ClientProfile::creating(function (ClientProfile $clientProfile) {
         if (\Sentry::check()) {
             $clientProfile->user_id = \Sentry::getUser()->id;
         }
     });
     // ClientComment about to be created
     ClientComment::creating(function (ClientComment $clientComment) {
         if (\Sentry::check()) {
             $clientComment->user_id = \Sentry::getUser()->id;
         }
     });
     /**
      * Tasks
      */
     // User assigned user to task
     TaskClient::created(function (TaskClient $taskClient) {
         Notification::notify(['from_user_id' => $taskClient->user_id, 'to_user_id' => $taskClient->client->user->id, 'icon' => 'tasks', 'message' => 'notification.task.assigned', 'message_parameters' => ['task' => $taskClient->task->title], 'url' => 'task.view', 'url_parameters' => ['id' => $taskClient->task->id]]);
     });
     // User assigned user to job
     TaskJobClient::created(function (TaskJobClient $taskJobClient) {
         Notification::notify(['from_user_id' => $taskJobClient->user_id, 'to_user_id' => $taskJobClient->client->user->id, 'icon' => 'tasks', 'message' => 'notification.task.job.assigned', 'message_parameters' => ['job' => $taskJobClient->job->title, 'task' => $taskJobClient->job->task->title], 'url' => 'task.job.view', 'url_parameters' => ['id' => $taskJobClient->job->id]]);
     });
     // User created new job for task
     TaskJob::created(function (TaskJob $taskJob) {
         foreach ($taskJob->task->clients as $client) {
             if (!isset($client->user->id)) {
                 continue;
             }
             Notification::notify(['from_user_id' => $taskJob->user_id, 'to_user_id' => $client->user->id, 'icon' => 'tasks', 'message' => 'notification.task.job.created', 'message_parameters' => ['job' => $taskJob->title, 'task' => $taskJob->task->title], 'url' => 'task.job.view', 'url_parameters' => ['id' => $taskJob->id]]);
         }
     });
     // Task about to be created
     Task::creating(function (Task $task) {
         if (\Sentry::check()) {
             $task->user_id = \Sentry::getUser()->id;
         }
     });
     // Task user assignment about to be created
     TaskClient::creating(function (TaskClient $taskClient) {
         if (\Sentry::check()) {
             $taskClient->user_id = \Sentry::getUser()->id;
         }
     });
     // Job about to be created
     TaskJob::creating(function (TaskJob $taskJob) {
         if (\Sentry::check()) {
             $taskJob->user_id = \Sentry::getUser()->id;
         }
     });
     // Job user assignment about to be created
     TaskJobClient::creating(function (TaskJobClient $taskJobClient) {
         if (\Sentry::check()) {
             $taskJobClient->user_id = \Sentry::getUser()->id;
         }
     });
     /**
      * Companies
      */
     // Company about to be created
     Company::creating(function (Company $company) {
         if (\Sentry::check()) {
             $company->user_id = \Sentry::getUser()->id;
         }
     });
     // Company department about to be created
     CompanyDepartment::creating(function (CompanyDepartment $companyDepartment) {
         if (\Sentry::check()) {
             $companyDepartment->user_id = \Sentry::getUser()->id;
         }
     });
     // Company user about to be created
     CompanyClient::creating(function (CompanyClient $companyClient) {
         if (\Sentry::check()) {
             $companyClient->user_id = \Sentry::getUser()->id;
         }
     });
     // Company profile about to be created
     CompanyProfile::creating(function (CompanyProfile $companyProfile) {
         if (\Sentry::check()) {
             $companyProfile->user_id = \Sentry::getUser()->id;
         }
     });
     /**
      * Invoices
      */
     // Save user ID for the invoice
     Invoice::creating(function (Invoice $invoice) {
         if (\Sentry::check()) {
             $invoice->user_id = \Sentry::getUser()->id;
         }
     });
     // Final invoices cannot be updated
     Invoice::updating(function (Invoice $invoice) {
         if ($invoice->final) {
             return false;
         }
     });
     // Save user ID for the invoice item
     InvoiceItem::creating(function (InvoiceItem $invoiceItem) {
         if (\Sentry::check()) {
             $invoiceItem->user_id = \Sentry::getUser()->id;
         }
     });
     // Items of final invoices cannot be updated
     InvoiceItem::updating(function (InvoiceItem $invoiceItem) {
         if ($invoiceItem->invoice->final) {
             return false;
         }
     });
     // Save user ID for the recurring invoice
     InvoiceRecurring::creating(function (InvoiceRecurring $invoiceRecurring) {
         if (\Sentry::check()) {
             $invoiceRecurring->user_id = \Sentry::getUser()->id;
         }
     });
     // Save user ID for the split invoice
     InvoiceSplit::creating(function (InvoiceSplit $invoiceSplit) {
         if (\Sentry::check()) {
             $invoiceSplit->user_id = \Sentry::getUser()->id;
         }
     });
     /**
      * Projects
      */
     // Save user ID for the Project
     Project::creating(function (Project $project) {
         if (\Sentry::check()) {
             $project->user_id = \Sentry::getUser()->id;
         }
     });
     // Save user ID for the ProjectProfile
     ProjectProfile::creating(function (ProjectProfile $projectProfile) {
         if (\Sentry::check()) {
             $projectProfile->user_id = \Sentry::getUser()->id;
         }
     });
     // Save user ID for the ProjectClient
     ProjectClient::creating(function (ProjectClient $projectClient) {
         if (\Sentry::check()) {
             $projectClient->user_id = \Sentry::getUser()->id;
         }
     });
     // Save user ID for the ProjectCompanyDepartment
     ProjectCompanyDepartment::creating(function (ProjectCompanyDepartment $projectCompanyDepartment) {
         if (\Sentry::check()) {
             $projectCompanyDepartment->user_id = \Sentry::getUser()->id;
         }
     });
     // Save user ID for the ProjectPhase
     ProjectPhase::creating(function (ProjectPhase $projectPhase) {
         if (\Sentry::check()) {
             $projectPhase->user_id = \Sentry::getUser()->id;
         }
     });
     // Save user ID for the ProjectPhaseDocument
     ProjectPhaseDocument::creating(function (ProjectPhaseDocument $projectPhaseDocument) {
         if (\Sentry::check()) {
             $projectPhaseDocument->user_id = \Sentry::getUser()->id;
         }
     });
     // Save user ID for the ProjectPhaseDocumentComment
     ProjectPhaseDocumentComment::creating(function (ProjectPhaseDocumentComment $projectPhaseDocumentComment) {
         if (\Sentry::check()) {
             $projectPhaseDocumentComment->user_id = \Sentry::getUser()->id;
         }
     });
 }
 /**
  * Move a project to the trash.
  *
  * @param int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     $project = Project::findOrFail($id);
     $project->delete();
     return redirect()->route('project.index');
 }
示例#8
0
 /**
  * Create a random Project.
  *
  * @param int VisualAppeal\Connect\Company $company (Default: null, newly created)
  *
  * @return VisualAppeal\Connect\Project
  */
 public function createProject($company = null)
 {
     $company = $company ?: $this->createCompany();
     return \VisualAppeal\Connect\Project::create(['company_id' => $company->id, 'title' => $this->faker->word]);
 }