diff --git a/app/Entities/Projects/Project.php b/app/Entities/Projects/Project.php index b3c249f..78735ef 100755 --- a/app/Entities/Projects/Project.php +++ b/app/Entities/Projects/Project.php @@ -3,6 +3,7 @@ namespace App\Entities\Projects; use App\Entities\Invoices\Invoice; +use App\Entities\Partners\Customer; use App\Entities\Payments\Payment; use App\Entities\Projects\ProjectPresenter; use App\Entities\Projects\Task; @@ -62,7 +63,7 @@ class Project extends Model public function customer() { - return $this->belongsTo(User::class, 'customer_id'); + return $this->belongsTo(Customer::class); } public function cashInTotal() diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index 9ccccfb..e285087 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -1,6 +1,7 @@ define(Project::class, function (Faker\Generator $faker) { return factory(User::class)->create()->id; }, 'customer_id' => function () { - return factory(User::class)->create()->id; + return factory(Customer::class)->create()->id; }, ]; }); diff --git a/resources/views/projects/partials/project-show.blade.php b/resources/views/projects/partials/project-show.blade.php index 494126c..9ce5ca9 100644 --- a/resources/views/projects/partials/project-show.blade.php +++ b/resources/views/projects/partials/project-show.blade.php @@ -16,7 +16,7 @@ {{ $project->present()->customerNameAndEmail }} @if ($project->customer_id && auth()->id() == $project->owner_id) - {!! link_to_route('users.edit', 'Edit', [$project->customer_id], ['title' => 'Edit Data Customer']) !!} + {!! link_to_route('users.edit', trans('app.edit'), [$project->customer_id], ['title' => trans('customer.edit')]) !!} @endif diff --git a/tests/Unit/Models/ProjectTest.php b/tests/Unit/Models/ProjectTest.php index 768f2ba..74768bf 100644 --- a/tests/Unit/Models/ProjectTest.php +++ b/tests/Unit/Models/ProjectTest.php @@ -2,6 +2,7 @@ namespace Tests\Unit\Models; +use App\Entities\Partners\Customer; use App\Entities\Payments\Payment; use App\Entities\Projects\Feature; use App\Entities\Projects\Project; @@ -14,7 +15,7 @@ use Tests\TestCase; class ProjectTest extends TestCase { /** @test */ - public function it_has_many_features() + public function a_project_has_many_features() { $project = factory(Project::class)->create(); $feature = factory(Feature::class)->create(['project_id' => $project->id]); @@ -23,7 +24,7 @@ class ProjectTest extends TestCase } /** @test */ - public function it_has_many_main_features() + public function a_project_has_many_main_features() { $project = factory(Project::class)->create(); $feature = factory(Feature::class)->create(['project_id' => $project->id, 'type_id' => 1]); @@ -32,7 +33,7 @@ class ProjectTest extends TestCase } /** @test */ - public function it_has_many_additional_features() + public function a_project_has_many_additional_features() { $project = factory(Project::class)->create(); $feature = factory(Feature::class)->create(['project_id' => $project->id, 'type_id' => 2]); @@ -41,7 +42,7 @@ class ProjectTest extends TestCase } /** @test */ - public function it_has_feature_tasks() + public function a_project_has_feature_tasks() { $project = factory(Project::class)->create(); $feature = factory(Feature::class)->create(['project_id' => $project->id, 'type_id' => 2]); @@ -51,7 +52,7 @@ class ProjectTest extends TestCase } /** @test */ - public function it_has_many_payments() + public function a_project_has_many_payments() { $project = factory(Project::class)->create(); $payment = factory(Payment::class)->create(['project_id' => $project->id]); @@ -60,7 +61,7 @@ class ProjectTest extends TestCase } /** @test */ - public function it_has_many_subscriptions() + public function a_project_has_many_subscriptions() { $project = factory(Project::class)->create(); $subscription = factory(Subscription::class)->create(['project_id' => $project->id]); @@ -69,14 +70,14 @@ class ProjectTest extends TestCase } /** @test */ - public function it_belongs_to_a_customer() + public function a_project_belongs_to_a_customer() { $project = factory(Project::class)->create(); - $this->assertTrue($project->customer instanceof User); + $this->assertTrue($project->customer instanceof Customer); } /** @test */ - public function it_has_cash_in_total_method() + public function a_project_has_cash_in_total_method() { $project = factory(Project::class)->create(); $payments = factory(Payment::class, 2)->create(['project_id' => $project->id, 'in_out' => 1, 'amount' => 20000]); @@ -84,7 +85,7 @@ class ProjectTest extends TestCase } /** @test */ - public function it_has_cash_out_total_method() + public function a_project_has_cash_out_total_method() { $project = factory(Project::class)->create(); $payments = factory(Payment::class, 2)->create(['project_id' => $project->id, 'in_out' => 0, 'amount' => 10000]); @@ -93,7 +94,7 @@ class ProjectTest extends TestCase } /** @test */ - public function it_has_feature_overall_progress_method() + public function a_project_has_feature_overall_progress_method() { $project = factory(Project::class)->create(); @@ -113,7 +114,7 @@ class ProjectTest extends TestCase } /** @test */ - public function it_returns_0_on_feature_overall_progress_method_if_all_feature_is_free() + public function a_project_returns_0_on_feature_overall_progress_method_if_all_feature_is_free() { $project = factory(Project::class)->create(); @@ -126,14 +127,14 @@ class ProjectTest extends TestCase } /** @test */ - public function it_has_many_files() + public function a_project_has_many_files() { $project = factory(Project::class)->create(); $this->assertTrue($project->files instanceof Collection); } /** @test */ - public function it_has_name_link_method() + public function a_project_has_name_link_method() { $project = factory(Project::class)->make(); $this->assertEquals(link_to_route('projects.show', $project->name, [$project->id]), $project->nameLink());