/** * @testdox A Job Resolution has an ID, name, and a type (which defaults to 'succeeded'). * @test */ public function basic() { $jobResolution = new JobResolution(); $jobResolution->save(); // Three JRs are created upon installation. $this->assertEquals(4, $jobResolution->id); $this->assertEquals('', $jobResolution->name); $this->assertEquals(JobResolution::SUCCEEDED, $jobResolution->type, 'Defaults to suceeded'); }
public function edit(Request $request, $id) { $job = Job::find($id); if (!$job) { abort(404); } $this->view->return_to = $request->query('return_to'); $this->view->title = 'Job #' . $job->id; $this->view->job = $job; $this->view->breadcrumbs = ['job-lists' => 'Job Lists', 'job-lists/' . $job->job_list_id => $job->jobList->name, 'jobs/' . $job->id => 'Job #' . $job->id]; $this->view->jobResolutions = JobResolution::all(); return $this->view; }
protected function jobLists() { if (!Schema::hasTable('job_types')) { $this->info("Creating 'job_types' table."); Schema::create('job_types', function (Blueprint $table) { $table->increments('id'); $table->string('name')->unique(); $table->string('colour'); $table->string('background_colour'); $table->boolean('contact_required')->default(true); $table->timestamps(); }); } if (!Schema::hasTable('crews')) { $this->info("Creating 'crews' table."); Schema::create('crews', function (Blueprint $table) { $table->increments('id'); $table->string('name')->unique(); $table->text('comments'); $table->timestamps(); }); } if (!Schema::hasTable('crew_members')) { $this->info("Creating 'crew_members' table."); Schema::create('crew_members', function (Blueprint $table) { $table->increments('id'); $table->integer('crew_id')->unsigned()->nullable(); $table->foreign('crew_id')->references('id')->on('crews'); $table->integer('user_id')->unsigned()->nullable(); $table->foreign('user_id')->references('id')->on('users'); $table->timestamps(); $table->unique(['crew_id', 'user_id']); }); } if (!Schema::hasTable('crew_unavailabilities')) { $this->info("Creating 'crew_unavailabilities' table."); Schema::create('crew_unavailabilities', function (Blueprint $table) { $table->increments('id'); $table->integer('crew_id')->unsigned()->nullable(); $table->foreign('crew_id')->references('id')->on('crews'); $table->date('start_date')->nullable(); $table->date('end_date')->nullable(); $table->integer('type_id')->unsigned()->nullable(); $table->foreign('type_id')->references('id')->on('unavailability_types'); $table->timestamps(); }); } if (!Schema::hasTable('job_lists')) { $this->info("Creating 'job_lists' table."); Schema::create('job_lists', function (Blueprint $table) { $table->increments('id'); $table->string('name')->unique(); $table->integer('type_id')->unsigned(); $table->foreign('type_id')->references('id')->on('job_types'); $table->integer('crew_id')->unsigned()->nullable(); $table->foreign('crew_id')->references('id')->on('crews'); $table->date('start_date')->nullable(); $table->date('due_date')->nullable(); $table->text('comments')->nullable(); $table->timestamps(); }); } if (!Schema::hasTable('job_list_tag')) { $this->info("Creating 'job_list_tag' table."); Schema::create('job_list_tag', function (Blueprint $table) { $table->integer('job_list_id')->unsigned(); $table->foreign('job_list_id')->references('id')->on('job_lists'); $table->integer('tag_id')->unsigned(); $table->foreign('tag_id')->references('id')->on('tags'); $table->primary(['job_list_id', 'tag_id']); }); } if (!Schema::hasTable('job_resolutions')) { $this->info("Creating 'job_resolutions' table."); Schema::create('job_resolutions', function (Blueprint $table) { $table->increments('id'); $table->string('name')->unique(); $table->enum('type', [JobResolution::SUCCEEDED, JobResolution::CANCELLED, JobResolution::FAILED])->default(JobResolution::SUCCEEDED); $table->text('comments'); $table->timestamps(); }); } $jobResolutionSucceeded = JobResolution::whereType(JobResolution::SUCCEEDED)->first(); if (!$jobResolutionSucceeded) { $this->info("Creating job-resolution 'succeeded'."); JobResolution::firstOrCreate(['id' => JobResolution::SUCCEEDED, 'name' => trans('job-resolutions.succeeded'), 'type' => JobResolution::SUCCEEDED]); } $jobResolutionCancelled = JobResolution::whereType(JobResolution::CANCELLED)->first(); if (!$jobResolutionCancelled) { $this->info("Creating job-resolution 'cancelled'."); JobResolution::firstOrCreate(['id' => JobResolution::CANCELLED, 'name' => trans('job-resolutions.cancelled'), 'type' => JobResolution::CANCELLED]); } $jobResolutionFailed = JobResolution::whereType(JobResolution::FAILED)->first(); if (!$jobResolutionFailed) { $this->info("Creating job-resolution 'failed'."); JobResolution::firstOrCreate(['id' => JobResolution::FAILED, 'name' => trans('job-resolutions.failed'), 'type' => JobResolution::FAILED]); } if (!Schema::hasTable('jobs')) { $this->info("Creating 'jobs' table."); Schema::create('jobs', function (Blueprint $table) { $table->increments('id'); $table->integer('job_list_id')->unsigned()->nullable(); $table->foreign('job_list_id')->references('id')->on('job_lists'); $table->integer('asset_id')->unsigned()->nullable(); $table->foreign('asset_id')->references('id')->on('assets'); $table->date('date_added')->comment('Date added to Job List.'); $table->date('date_removed')->nullable()->comment('Date removed from Job List.'); $table->date('date_resolved')->nullable()->comment('Date of completion or failure.'); $table->integer('resolution_id')->unsigned()->nullable(); $table->foreign('resolution_id')->references('id')->on('job_resolutions'); $table->text('instructions')->nullable(); $table->text('resolution_comments')->nullable(); $table->timestamps(); $table->unique(['job_list_id', 'asset_id']); }); } if (!Schema::hasTable('contact_attempts')) { $this->info("Creating 'contact_attempts' table."); Schema::create('contact_attempts', function (Blueprint $table) { $table->increments('id'); $table->integer('job_id')->unsigned(); $table->foreign('job_id')->references('id')->on('jobs'); $table->integer('contact_id')->unsigned(); $table->foreign('contact_id')->references('id')->on('contacts'); $table->integer('user_id')->unsigned(); $table->foreign('user_id')->references('id')->on('users'); $table->dateTime('date_and_time_attempted'); $table->boolean('contact_made')->default(false); $table->text('comments'); $table->timestamps(); }); } if (!Schema::hasTable('job_tag')) { $this->info("Creating 'job_tag' table."); Schema::create('job_tag', function (Blueprint $table) { $table->integer('job_id')->unsigned(); $table->foreign('job_id')->references('id')->on('jobs'); $table->integer('tag_id')->unsigned(); $table->foreign('tag_id')->references('id')->on('tags'); $table->primary(['job_id', 'tag_id']); }); } }