1 | <?php |
||
21 | abstract class Model implements Arrayable, Jsonable, Stringable, JsonSerializable |
||
22 | { |
||
23 | use Presentable, Eventable, Mergeable; |
||
24 | use Idable, Fillable, Cacheable; |
||
25 | |||
26 | /** |
||
27 | * @var IDAL |
||
28 | */ |
||
29 | public $_dal; |
||
30 | |||
31 | /** |
||
32 | * @var bool |
||
33 | */ |
||
34 | public $_exist = false; |
||
35 | |||
36 | /** |
||
37 | * Create a new instance. |
||
38 | * |
||
39 | * @param IDAL $dal |
||
40 | * @param array $attributes |
||
41 | */ |
||
42 | 52 | public function __construct(IDAL $dal, array $attributes = []) |
|
43 | { |
||
44 | 52 | $this->_dal = $dal; |
|
45 | |||
46 | 52 | $this->fill($attributes); |
|
47 | 52 | } |
|
48 | |||
49 | /** |
||
50 | * {@inheritdoc} |
||
51 | */ |
||
52 | 28 | public function toArray() |
|
53 | 2 | { |
|
54 | 28 | return array_where(get_object_vars($this), function ($key) { |
|
55 | 28 | return !starts_with($key, '_'); |
|
56 | 28 | }); |
|
57 | } |
||
58 | |||
59 | /** |
||
60 | * {@inheritdoc} |
||
61 | */ |
||
62 | public function jsonSerialize() |
||
63 | { |
||
64 | return $this->toArray(); |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * Save the model. |
||
69 | * |
||
70 | * @param array $columns |
||
71 | * @return bool |
||
72 | */ |
||
73 | 24 | public function save($columns = ['*']) |
|
74 | { |
||
75 | 24 | $columns = $columns ? (array)$columns : ['*']; |
|
76 | |||
77 | 24 | if ($this->saving() === false) { |
|
78 | return false; |
||
79 | } |
||
80 | |||
81 | 24 | if (method_exists($this, 'fillTimestamp')) { |
|
82 | 24 | $this->fillTimestamp(); |
|
|
|||
83 | 24 | } |
|
84 | |||
85 | 24 | $this->_dal->put($columns); |
|
86 | |||
87 | 24 | $this->_exist = true; |
|
88 | |||
89 | // self::cache()->put($id, $this); |
||
90 | |||
91 | 24 | if ($this->saved() === false) { |
|
92 | return false; |
||
93 | } |
||
94 | |||
95 | 24 | return true; |
|
96 | } |
||
97 | |||
98 | /** |
||
99 | * Delete the model. |
||
100 | * |
||
101 | * @return bool |
||
102 | */ |
||
103 | 6 | public function delete() |
|
122 | |||
123 | /** |
||
124 | * Create a new instance. |
||
125 | * |
||
126 | * @return static |
||
127 | */ |
||
128 | public static function createInstance() |
||
132 | |||
133 | /** |
||
134 | * Find a model by its primary key. |
||
135 | * |
||
136 | * @param mixed $id |
||
137 | * @param array $columns |
||
138 | * @param array $options |
||
139 | * @return static |
||
140 | */ |
||
141 | 22 | public static function find($id, array $columns = ['*'], $options = []) |
|
174 | |||
175 | /** |
||
176 | * Find a model by its primary key or return new model. |
||
177 | * |
||
178 | * @param mixed $id |
||
179 | * @return static |
||
180 | */ |
||
181 | 2 | public static function findOrNew($id) |
|
190 | |||
191 | /** |
||
192 | * Find a model by its primary key or throw an exception. |
||
193 | * |
||
194 | * @param mixed $id |
||
195 | * @param array $columns |
||
196 | * @param int $parent |
||
197 | * @return static |
||
198 | */ |
||
199 | 4 | public static function findOrFail($id, array $columns = ['*'], $parent = null) |
|
207 | |||
208 | /** |
||
209 | * Save a new model and return the instance. |
||
210 | * |
||
211 | * @param array $attributes |
||
212 | * @throws Exception |
||
213 | * @return static |
||
214 | */ |
||
215 | 8 | public static function create(array $attributes = []) |
|
229 | |||
230 | /** |
||
231 | * Destroy the models by the given id. |
||
232 | * |
||
233 | * @param mixed $id |
||
234 | */ |
||
235 | 2 | public static function destroy($id) |
|
245 | } |
||
246 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.