diff --git a/app/Entities/Projects/Issue.php b/app/Entities/Projects/Issue.php
new file mode 100644
index 0000000..44f1658
--- /dev/null
+++ b/app/Entities/Projects/Issue.php
@@ -0,0 +1,10 @@
+hasMany(Issue::class);
+ }
}
diff --git a/app/Http/Controllers/Projects/IssueController.php b/app/Http/Controllers/Projects/IssueController.php
new file mode 100644
index 0000000..fe977e1
--- /dev/null
+++ b/app/Http/Controllers/Projects/IssueController.php
@@ -0,0 +1,16 @@
+issues;
+
+ return view('projects.issues', compact('project', 'issues'));
+ }
+}
diff --git a/database/factories/IssueFactory.php b/database/factories/IssueFactory.php
new file mode 100644
index 0000000..a99dc3b
--- /dev/null
+++ b/database/factories/IssueFactory.php
@@ -0,0 +1,15 @@
+define(Issue::class, function (Faker $faker) {
+ return [
+ 'project_id' => function () {
+ return factory(Project::class)->create()->id;
+ },
+ 'title' => $faker->words(3, true),
+ 'body' => $faker->sentences(3, true),
+ ];
+});
diff --git a/database/migrations/2019_03_03_210017_create_issues_table.php b/database/migrations/2019_03_03_210017_create_issues_table.php
new file mode 100644
index 0000000..d2cf1ab
--- /dev/null
+++ b/database/migrations/2019_03_03_210017_create_issues_table.php
@@ -0,0 +1,34 @@
+increments('id');
+ $table->unsignedInteger('project_id');
+ $table->string('title', 60);
+ $table->string('body');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('issues');
+ }
+}
diff --git a/resources/views/projects/issues.blade.php b/resources/views/projects/issues.blade.php
new file mode 100755
index 0000000..8011433
--- /dev/null
+++ b/resources/views/projects/issues.blade.php
@@ -0,0 +1,32 @@
+@extends('layouts.project')
+
+@section('subtitle', __('project.issues'))
+
+@section('content-project')
+
+
+
{{ __('project.issues') }}
+
+
+
+ | {{ __('app.table_no') }} |
+ {{ __('issue.name') }} |
+ {{ __('app.action') }} |
+
+
+ @forelse($issues as $key => $issue)
+ @php
+ $no = 1 + $key;
+ @endphp
+
+ | {{ $no }} |
+ {{ $issue->title }} |
+ |
+
+ @empty
+ | {{ __('issue.empty') }} |
+ @endforelse
+
+
+
+@endsection
diff --git a/routes/web/projects.php b/routes/web/projects.php
index c1b6deb..61fab86 100644
--- a/routes/web/projects.php
+++ b/routes/web/projects.php
@@ -46,6 +46,11 @@ Route::group(['middleware' => ['auth'], 'namespace' => 'Projects'], function ()
Route::delete('projects/{project}/comments/{comment}', 'CommentsController@destroy')->name('projects.comments.destroy');
/*
+ * Project Issues Routes
+ */
+ Route::get('projects/{project}/issues', 'IssueController@index')->name('projects.issues.index');
+
+ /*
* Tasks Routes
*/
Route::get('jobs/{job}/tasks/create', ['as' => 'tasks.create', 'uses' => 'TasksController@create']);
diff --git a/tests/Feature/Projects/ProjectIssuesTest.php b/tests/Feature/Projects/ProjectIssuesTest.php
index bd3cc51..59c1ecf 100644
--- a/tests/Feature/Projects/ProjectIssuesTest.php
+++ b/tests/Feature/Projects/ProjectIssuesTest.php
@@ -3,6 +3,8 @@
namespace Tests\Feature\Projects;
use Tests\TestCase;
+use App\Entities\Projects\Issue;
+use App\Entities\Projects\Project;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ProjectIssuesTest extends TestCase
@@ -24,7 +26,6 @@ class ProjectIssuesTest extends TestCase
$this->seeRouteIs('projects.issues.index', $project);
$this->seeText('The issue title.');
- $this->seeText('This is a project issue.');
}
/** @test */
diff --git a/tests/Unit/Models/ProjectTest.php b/tests/Unit/Models/ProjectTest.php
index ff9a2f7..5164333 100644
--- a/tests/Unit/Models/ProjectTest.php
+++ b/tests/Unit/Models/ProjectTest.php
@@ -6,6 +6,7 @@ use Tests\TestCase;
use App\Entities\Projects\Job;
use App\Entities\Projects\File;
use App\Entities\Projects\Task;
+use App\Entities\Projects\Issue;
use App\Entities\Invoices\Invoice;
use App\Entities\Payments\Payment;
use App\Entities\Projects\Comment;
@@ -350,4 +351,14 @@ class ProjectTest extends TestCase
'project_id' => $project->id,
]);
}
+
+ /** @test */
+ public function a_project_has_many_issues_relation()
+ {
+ $project = factory(Project::class)->create();
+ $issue = factory(Issue::class)->create(['project_id' => $project->id]);
+
+ $this->assertInstanceOf(Collection::class, $project->issues);
+ $this->assertInstanceOf(Issue::class, $project->issues->first());
+ }
}