1 | <?php |
||
11 | trait ImageField |
||
12 | { |
||
13 | /** |
||
14 | * Intervention calls. |
||
15 | * |
||
16 | * @var array |
||
17 | */ |
||
18 | protected $interventionCalls = []; |
||
19 | |||
20 | /** |
||
21 | * Thumbnail settings. |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $thumbnails = []; |
||
26 | |||
27 | /** |
||
28 | * Default directory for file to upload. |
||
29 | * |
||
30 | * @return mixed |
||
31 | */ |
||
32 | public function defaultDirectory() |
||
36 | |||
37 | /** |
||
38 | * Execute Intervention calls. |
||
39 | * |
||
40 | * @param string $target |
||
41 | * |
||
42 | * @return mixed |
||
43 | */ |
||
44 | public function callInterventionMethods($target) |
||
59 | |||
60 | /** |
||
61 | * Call intervention methods. |
||
62 | * |
||
63 | * @param string $method |
||
64 | * @param array $arguments |
||
65 | * |
||
66 | * @throws \Exception |
||
67 | * |
||
68 | * @return $this |
||
69 | */ |
||
70 | public function __call($method, $arguments) |
||
87 | |||
88 | /** |
||
89 | * Render a image form field. |
||
90 | * |
||
91 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
||
92 | */ |
||
93 | public function render() |
||
99 | |||
100 | /** |
||
101 | * @param string|array $name |
||
102 | * @param int $width |
||
103 | * @param int $height |
||
104 | * |
||
105 | * @return $this |
||
106 | */ |
||
107 | public function thumbnail($name, int $width = null, int $height = null) |
||
121 | |||
122 | /** |
||
123 | * Destroy original thumbnail files. |
||
124 | * |
||
125 | * @return void. |
||
126 | */ |
||
127 | public function destroyThumbnail() |
||
151 | |||
152 | /** |
||
153 | * Remove thumbnail file from disk. |
||
154 | * |
||
155 | * @return void. |
||
156 | */ |
||
157 | public function destroyThumbnailFile($original, $name) |
||
172 | |||
173 | /** |
||
174 | * Upload file and delete original thumbnail files. |
||
175 | * |
||
176 | * @param UploadedFile $file |
||
177 | * |
||
178 | * @return $this |
||
179 | */ |
||
180 | protected function uploadAndDeleteOriginalThumbnail(UploadedFile $file) |
||
212 | } |
||
213 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: