Esempio n. 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     /**
      * VisualAppeal
      */
     // ID 1
     $visualappeal = \VisualAppeal\Connect\Company::create(['name' => 'VisualAppeal', 'phone' => '+49 123 456789', 'email' => '*****@*****.**', 'website' => 'http://www.visualappeal.de']);
     // ID 1
     \VisualAppeal\Connect\CompanyClient::create(['employee_client_id' => 1, 'company_id' => $visualappeal->id, 'joined_at' => \Carbon\Carbon::now()->subDays(753)]);
     /**
      * IBM
      */
     // ID 2
     $ibm = \VisualAppeal\Connect\Company::create(['name' => 'IBM']);
     // ID 1
     $devOps = \VisualAppeal\Connect\CompanyDepartment::create(['company_id' => $ibm->id, 'name' => 'DevOps', 'phone' => '+10 4123 173 (0)', 'email' => '*****@*****.**', 'website' => 'https://devops.ibm.com']);
     // ID 2
     $design = \VisualAppeal\Connect\CompanyDepartment::create(['company_id' => $ibm->id, 'name' => 'Design']);
     // ID 2
     \VisualAppeal\Connect\CompanyClient::create(['employee_client_id' => 2, 'company_id' => $ibm->id, 'joined_at' => \Carbon\Carbon::now()->subDays(723), 'company_department_id' => $devOps->id]);
     // ID 3
     \VisualAppeal\Connect\CompanyClient::create(['employee_client_id' => 4, 'company_id' => $ibm->id, 'joined_at' => \Carbon\Carbon::now()->subDays(723), 'company_department_id' => $devOps->id]);
     // ID 4
     \VisualAppeal\Connect\CompanyClient::create(['employee_client_id' => 5, 'company_id' => $ibm->id, 'joined_at' => \Carbon\Carbon::now()->subDays(354), 'company_department_id' => $design->id]);
     // ID 5
     \VisualAppeal\Connect\CompanyClient::create(['employee_client_id' => 6, 'company_id' => $ibm->id, 'joined_at' => \Carbon\Carbon::now()->subDays(348)]);
     // ID 1
     \VisualAppeal\Connect\CompanyProfile::create(['company_id' => $ibm->id, 'title' => 'foundation', 'value' => '1911']);
 }
Esempio n. 2
0
 /**
  * Test that a company can be deleted via interface.
  */
 public function testDeleteForm()
 {
     $admin = $this->createSuperuser();
     $this->be($admin);
     $company = $this->createCompany();
     $this->call('GET', route('company.show', ['company' => $company->id]));
     $this->assertResponseOk();
     $response = $this->call('DELETE', route('company.destroy', ['company' => $company->id]), ['_token' => Session::token()]);
     $this->assertRedirectedToRoute('company.index');
     $company = \VisualAppeal\Connect\Company::find(1);
     $this->assertNull($company);
 }
 /**
  * Delete employee.
  *
  * @param int $companyId
  * @param int $employeeId
  *
  * @return Response
  */
 public function destroy($companyId, $employeeId)
 {
     $company = Company::where('id', '=', $companyId)->firstOrFail();
     $employee = CompanyClient::where('id', '=', $employeeId)->firstOrFail();
     $employee->delete();
     return redirect()->route('company.show', ['company' => $company->id]);
 }
 /**
  * Move a company to the trash.
  *
  * @param int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     $company = Company::findOrFail($id);
     $company->delete();
     return redirect()->route('company.index');
 }
 /**
  * Delete profile field.
  *
  * @param int $companyId
  * @param int $profileId
  *
  * @return Response
  */
 public function destroy($companyId, $profileId)
 {
     $company = Company::findOrFail($companyId);
     $profile = CompanyProfile::findOrFail($profileId);
     $profile->delete();
     return redirect()->route('company.show', ['company' => $company->id]);
 }
 /**
  * Delete department.
  *
  * @param int $companyId
  * @param int $departmentId
  *
  * @return Response
  */
 public function destroy($companyId, $departmentId)
 {
     $company = Company::findOrFail($companyId);
     $department = CompanyDepartment::findOrFail($departmentId);
     $department->delete();
     return redirect()->route('company.show', ['company' => $company->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;
         }
     });
 }
 /**
  * Show the form to edit a Project.
  *
  * @param int $id
  *
  * @return Response
  */
 public function edit($id)
 {
     $project = Project::findOrFail($id);
     $companies = Company::all()->lists('name', 'id');
     return view('project.edit', ['project' => $project, 'companies' => $companies]);
 }
Esempio n. 9
0
 /**
  * Create a random Company.
  *
  * @param VisualAppeal\Connect\User $user (Default: null, newly created)
  *
  * @return VisualAppeal\Connect\Company
  */
 protected function createCompany($user = null)
 {
     $user = $user ?: $this->createUser();
     return \VisualAppeal\Connect\Company::create(['user_id' => $user->id, 'name' => $this->faker->sentence(2), 'phone' => $this->faker->boolean(50) ? $this->faker->phoneNumber : null, 'fax' => $this->faker->boolean(50) ? $this->faker->phoneNumber : null, 'email' => $this->faker->boolean(50) ? $this->faker->email : null, 'website' => $this->faker->boolean(50) ? $this->faker->url : null]);
 }