Browse Source

Add default attribute on issue pic relation

pull/37/head
Nafies Luthfi 7 years ago
parent
commit
f6b0aa98dc
  1. 2
      app/Entities/Projects/Issue.php
  2. 6
      resources/lang/de/issue.php
  3. 6
      resources/lang/en/issue.php
  4. 6
      resources/lang/id/issue.php
  5. 8
      tests/Unit/Models/IssueTest.php

2
app/Entities/Projects/Issue.php

@ -17,7 +17,7 @@ class Issue extends Model
public function pic()
{
return $this->belongsTo(User::class);
return $this->belongsTo(User::class)->withDefault(['name' => __('issue.no_pic')]);
}
public function creator()

6
resources/lang/de/issue.php

@ -13,6 +13,7 @@ return [
'empty' => 'Issue is empty.',
'back_to_show' => 'Back to Issue Detail',
'back_to_index' => 'Back to Issue List',
'no_pic' => 'No issue PIC',
// Actions
'create' => 'Create new Issue',
@ -34,4 +35,9 @@ return [
// Attributes
'title' => 'Issue Title',
'body' => 'Issue Description',
// Relations
'project' => 'Issue Project',
'pic' => 'Issue PIC',
'creator' => 'Issue Creator',
];

6
resources/lang/en/issue.php

@ -13,6 +13,7 @@ return [
'empty' => 'Issue is empty.',
'back_to_show' => 'Back to Issue Detail',
'back_to_index' => 'Back to Issue List',
'no_pic' => 'No issue PIC',
// Actions
'create' => 'Create new Issue',
@ -34,4 +35,9 @@ return [
// Attributes
'title' => 'Issue Title',
'body' => 'Issue Description',
// Relations
'project' => 'Issue Project',
'pic' => 'Issue PIC',
'creator' => 'Issue Creator',
];

6
resources/lang/id/issue.php

@ -13,6 +13,7 @@ return [
'empty' => 'Belum ada Issue',
'back_to_show' => 'Kembali ke detail Issue',
'back_to_index' => 'Kembali ke daftar Issue',
'no_pic' => 'Belum ada PIC',
// Actions
'create' => 'Input Issue Baru',
@ -34,4 +35,9 @@ return [
// Attributes
'title' => 'Judul Issue',
'body' => 'Deskripsi Issue',
// Relations
'project' => 'Project Issue',
'pic' => 'PIC Issue',
'creator' => 'Pembuat Issue',
];

8
tests/Unit/Models/IssueTest.php

@ -32,6 +32,14 @@ class IssueTest extends TestCase
}
/** @test */
public function issue_pic_name_has_default_value()
{
$issue = factory(Issue::class)->make(['pic_id' => null]);
$this->assertEquals(__('issue.no_pic'), $issue->pic->name);
}
/** @test */
public function an_issue_has_belongs_to_creator_relation()
{
$issue = factory(Issue::class)->make();

Loading…
Cancel
Save