Browse Source

Show only on progress jobs on user job list tab

pull/6/head
Nafies Luthfi 8 years ago
parent
commit
e80eb17bff
  1. 7
      app/Http/Controllers/Users/JobsController.php
  2. 9
      tests/Unit/Models/JobTest.php

7
app/Http/Controllers/Users/JobsController.php

@ -14,8 +14,11 @@ class JobsController extends Controller
{ {
public function index(User $user) public function index(User $user)
{ {
$jobs = $user->jobs()
->latest()
$jobs = $user->jobs()->whereHas('tasks', function ($query) {
return $query->where('progress', '<', 100);
})->whereHas('project', function ($query) {
return $query->whereIn('status_id', [2, 3]);
})->where('worker_id', $user->id)
->with(['tasks', 'project']) ->with(['tasks', 'project'])
->paginate(); ->paginate();

9
tests/Unit/Models/JobTest.php

@ -47,6 +47,15 @@ class JobTest extends TestCase
} }
/** @test */ /** @test */
public function a_job_with_no_tasks_will_return_0_on_progress_attribute()
{
$job = factory(Job::class)->create();
// Job progress = job tasks average progress
$this->assertEquals(0, $job->progress);
}
/** @test */
public function a_job_has_receiveable_earning_attribute() public function a_job_has_receiveable_earning_attribute()
{ {
$job = factory(Job::class)->create(['price' => 1000]); $job = factory(Job::class)->create(['price' => 1000]);

Loading…
Cancel
Save