1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Telefonica\Models\Actors; |
4
|
|
|
|
5
|
|
|
use Pedreiro\Models\Base; |
6
|
|
|
use Templeiro\Models\Data; |
7
|
|
|
use Telefonica\Traits\AsHuman; |
8
|
|
|
use Cocur\Slugify\Slugify; |
9
|
|
|
use Telefonica\Traits\AsOrganization; |
10
|
|
|
|
11
|
|
|
class Business extends Base |
12
|
|
|
{ |
13
|
|
|
use AsOrganization; |
14
|
|
|
|
15
|
|
|
public $incrementing = false; |
16
|
|
|
protected $casts = [ |
17
|
|
|
'code' => 'string', |
18
|
|
|
]; |
19
|
|
|
protected $primaryKey = 'code'; |
20
|
|
|
protected $keyType = 'string'; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* The attributes that are mass assignable. |
24
|
|
|
* |
25
|
|
|
* @var array |
26
|
|
|
*/ |
27
|
|
|
protected $fillable = [ |
28
|
|
|
'name', |
29
|
|
|
'code', |
30
|
|
|
'language_code', |
31
|
|
|
'money_code', |
32
|
|
|
'user_id' |
33
|
|
|
]; |
34
|
|
|
|
35
|
|
|
protected $mappingProperties = array( |
36
|
|
|
'name' => [ |
37
|
|
|
'type' => 'string', |
38
|
|
|
"analyzer" => "standard", |
39
|
|
|
], |
40
|
|
|
'code' => [ |
41
|
|
|
'type' => 'string', |
42
|
|
|
"analyzer" => "standard", |
43
|
|
|
], |
44
|
|
|
'language_code' => [ |
45
|
|
|
'type' => 'string', |
46
|
|
|
"analyzer" => "standard", |
47
|
|
|
], |
48
|
|
|
'money_code' => [ |
49
|
|
|
'type' => 'string', |
50
|
|
|
"analyzer" => "standard", |
51
|
|
|
], |
52
|
|
|
'user_id' => [ |
53
|
|
|
'type' => 'string', |
54
|
|
|
"analyzer" => "standard", |
55
|
|
|
], |
56
|
|
|
); |
57
|
|
|
|
58
|
|
|
// /** |
59
|
|
|
// * Get all of the owning businessable models. |
60
|
|
|
// */ |
61
|
|
|
// @todo A relacao porliformica é diferente nesse caso, podemos ter varias pessoas associadas ao mesmo item. |
62
|
|
|
// public function businessable() |
63
|
|
|
// { |
64
|
|
|
// return $this->morphTo(); //, 'businessable_type', 'businessable_code' |
65
|
|
|
// } |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Get all of the users that are assigned this tag. |
69
|
|
|
*/ |
70
|
|
|
public function users() |
71
|
|
|
{ |
72
|
|
|
return $this->morphedByMany(\Illuminate\Support\Facades\Config::get('sitec.core.models.user', \App\Models\User::class), 'businessable'); //, 'businessable_type', 'businessable_code'); |
73
|
|
|
} |
74
|
|
|
public function collaborators() |
75
|
|
|
{ |
76
|
|
|
return $this->morphedByMany(Person::class, 'businessable'); //, 'businessable_type', 'businessable_code'); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function datas() |
80
|
|
|
{ |
81
|
|
|
return $this->morphMany(Data::class, 'datable'); //, 'datable_type', 'datable_code'); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
|
85
|
|
|
} |