1 | <?php |
||
16 | abstract class AbstractEntity extends Model implements Presentable |
||
17 | { |
||
18 | /** |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $columns; |
||
22 | |||
23 | /** |
||
24 | * FEITO O PULL REQUEST # ATE SER SOLICITADO |
||
25 | * INICIO: Prettus\Repository\Traits\PresentableTrait |
||
26 | */ |
||
27 | /** |
||
28 | * @var PresenterInterface |
||
29 | */ |
||
30 | protected $presenter = null; |
||
31 | |||
32 | /** |
||
33 | * @param \Prettus\Repository\Contracts\PresenterInterface $presenter |
||
34 | * |
||
35 | * @return $this |
||
36 | */ |
||
37 | 2 | public function setPresenter(PresenterInterface $presenter) |
|
38 | { |
||
39 | 2 | $this->presenter = $presenter; |
|
40 | |||
41 | 2 | return $this; |
|
42 | } |
||
43 | |||
44 | /** |
||
45 | * @param $key |
||
46 | * @param null $default |
||
47 | * |
||
48 | * @return mixed|null |
||
49 | */ |
||
50 | public function present($key, $default = null) |
||
60 | |||
61 | /** |
||
62 | * @return bool |
||
63 | */ |
||
64 | 3 | public function hasPresenter() |
|
65 | { |
||
66 | 3 | return isset($this->presenter) && $this->presenter instanceof PresenterInterface; |
|
67 | } |
||
68 | |||
69 | /** |
||
70 | * @return $this|mixed |
||
71 | */ |
||
72 | 2 | public function presenter() |
|
73 | { |
||
74 | 2 | if ($this->hasPresenter()) { |
|
75 | 1 | return $this->presenter->present($this); |
|
76 | } |
||
77 | |||
78 | 1 | return $this; |
|
79 | } |
||
80 | /** |
||
81 | * FIM Prettus\Repository\Traits\PresentableTrait |
||
82 | */ |
||
83 | |||
84 | /** |
||
85 | * Set a given attribute on the model. |
||
86 | * |
||
87 | * @param string $key String Key |
||
88 | * @param mixed $value Mixed Value |
||
89 | * |
||
90 | * @return void |
||
91 | */ |
||
92 | 14 | public function setAttribute($key, $value) |
|
104 | |||
105 | /** |
||
106 | * Get an attribute from the $attributes array. |
||
107 | * |
||
108 | * @param string $key String Key |
||
109 | * |
||
110 | * @return mixed |
||
111 | */ |
||
112 | 1 | public function getRawAttribute($key) |
|
116 | |||
117 | /** |
||
118 | * Lista de Colunas |
||
119 | * |
||
120 | * @return array |
||
121 | */ |
||
122 | 1 | public function columns() |
|
141 | |||
142 | /** |
||
143 | * Is Column in Table |
||
144 | * |
||
145 | * @param string $key String Key |
||
146 | * |
||
147 | * @return bool |
||
148 | */ |
||
149 | 1 | public function isColumn($key) |
|
153 | |||
154 | /** |
||
155 | * Retorna o ultimo id registrado |
||
156 | * |
||
157 | * @return int |
||
158 | */ |
||
159 | 1 | public function lastInsertId() |
|
163 | |||
164 | /** |
||
165 | * Convert a DateTime to a storable string. |
||
166 | * |
||
167 | * @param \DateTime|int $value Date Time\Integer Value |
||
168 | * @return string |
||
169 | */ |
||
170 | 1 | public function fromDateTime($value) |
|
178 | |||
179 | /** |
||
180 | * Return a timestamp as DateTime object. |
||
181 | * |
||
182 | * @param mixed $value Mixed Value |
||
183 | * @return \Carbon\Carbon |
||
184 | */ |
||
185 | 3 | public function asDateTime($value) |
|
186 | 1 | { |
|
187 | 3 | $value = asDateTime($value); |
|
188 | 3 | if (empty($value)) { |
|
189 | 2 | return $value; |
|
190 | 1 | } |
|
191 | |||
192 | 2 | return parent::asDateTime($value); |
|
193 | } |
||
194 | |||
195 | /** |
||
196 | * Scope Where Criteria |
||
197 | * |
||
198 | * @param unknown $query Query |
||
199 | * @param array $input Input |
||
200 | * |
||
201 | * @return mixed |
||
202 | */ |
||
203 | 1 | public function scopeWhereCriteria($query, array $input) |
|
208 | } |
||
209 |