Total Complexity | 5 |
Total Lines | 59 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
9 | trait Lincable |
||
10 | { |
||
11 | /** |
||
12 | * Boot the model statically. |
||
13 | * |
||
14 | * @return void |
||
15 | */ |
||
16 | public static function bootLincable() |
||
17 | { |
||
18 | static::creating(function ($model) { |
||
19 | $model->addLincableFields(); |
||
20 | }); |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * Add the lincable fields to model fillables. |
||
25 | * |
||
26 | * @return void |
||
27 | */ |
||
28 | public function addLincableField() |
||
29 | { |
||
30 | // Get the model fillable fields. |
||
31 | $fillables = $this->getFillable(); |
||
|
|||
32 | |||
33 | $this->fillable(array_merge($fillables, [$this->getUrlField()])); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * Link the model to a file. |
||
38 | * |
||
39 | * @param mixed $file |
||
40 | * @return this |
||
41 | */ |
||
42 | public function link($file) |
||
43 | { |
||
44 | // Resolve the file object to link the model. It can |
||
45 | // be a symfony uploaded file or a file request, which |
||
46 | // is preferable for linking. |
||
47 | $file = FileResolver::resolve($file); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Return the url field to link the model. |
||
52 | * |
||
53 | * @return string |
||
54 | */ |
||
55 | public function getUrlField() |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * Return a media manager instance. |
||
62 | * |
||
63 | * @return \Lincable\MediaManager |
||
64 | */ |
||
65 | protected function getMediaManager() |
||
68 | } |
||
69 | } |