|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Models\Concerns\User; |
|
4
|
|
|
|
|
5
|
|
|
use App\Models\Branch; |
|
6
|
|
|
use App\Models\Support\Relation\MorphManyIssueCustomers; |
|
7
|
|
|
use App\Models\Support\Relation\MorphManyIssueOrderStatus; |
|
8
|
|
|
use Illuminate\Database\Eloquent\Collection; |
|
9
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo; |
|
10
|
|
|
use Spatie\Permission\Traits\HasRoles; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection<\App\Models\Role> $roles |
|
14
|
|
|
* @property int $branch_id Foreign key of \App\Models\Branch. |
|
15
|
|
|
* @property-read \App\Models\Branch $branch |
|
16
|
|
|
* |
|
17
|
|
|
* @see \App\Models\User |
|
18
|
|
|
*/ |
|
19
|
|
|
trait Relation |
|
20
|
|
|
{ |
|
21
|
|
|
use HasRoles, |
|
22
|
|
|
MorphManyIssueOrderStatus, |
|
23
|
|
|
MorphManyIssueCustomers; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Define an inverse one-to-one or many relationship with \App\Models\Branch. |
|
27
|
|
|
* |
|
28
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
29
|
|
|
*/ |
|
30
|
73 |
|
public function branch(): BelongsTo |
|
31
|
|
|
{ |
|
32
|
73 |
|
return $this->belongsTo(Branch::class); |
|
|
|
|
|
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Return \App\Models\Branch model relation value. |
|
37
|
|
|
* |
|
38
|
|
|
* @return \App\Models\Branch |
|
39
|
|
|
*/ |
|
40
|
|
|
public function getBranchRelationValue(): Branch |
|
41
|
|
|
{ |
|
42
|
|
|
return $this->getRelationValue('branch'); |
|
|
|
|
|
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Set \App\Models\Branch model relation value. |
|
47
|
|
|
* |
|
48
|
|
|
* @param \App\Models\Branch $branch |
|
49
|
|
|
* @return $this |
|
50
|
|
|
*/ |
|
51
|
73 |
|
public function setBranchRelationValue(Branch $branch) |
|
52
|
|
|
{ |
|
53
|
73 |
|
$this->branch()->associate($branch); |
|
54
|
|
|
|
|
55
|
73 |
|
return $this; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Return collection of \App\Models\Order model relation value. |
|
60
|
|
|
* |
|
61
|
|
|
* @return \Illuminate\Database\Eloquent\Collection<\App\Models\Contracts\Issuerable> |
|
62
|
|
|
*/ |
|
63
|
|
|
public function getIssuersRelationValue(): Collection |
|
64
|
|
|
{ |
|
65
|
|
|
return $this->issuerOrderStatuses->merge($this->issuerCustomers); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|