1 | <?php |
||
16 | trait HasMediaTrait |
||
17 | { |
||
18 | /** |
||
19 | * @var array |
||
20 | */ |
||
21 | public $mediaConversions = []; |
||
22 | |||
23 | /** |
||
24 | * @var bool |
||
25 | */ |
||
26 | private $deletePreservingMedia = false; |
||
27 | |||
28 | public static function bootHasMediaTrait() |
||
38 | |||
39 | /** |
||
40 | * Set the polymorphic relation. |
||
41 | * |
||
42 | * @return mixed |
||
43 | */ |
||
44 | public function media() |
||
48 | |||
49 | /** |
||
50 | * Add a file to the medialibrary. The file will be removed from |
||
51 | * it's original location. |
||
52 | * |
||
53 | * @param string|\Symfony\Component\HttpFoundation\File\UploadedFile $file |
||
54 | * |
||
55 | * @return \Spatie\MediaLibrary\FileAdder\FileAdder |
||
56 | */ |
||
57 | public function addMedia($file) |
||
61 | |||
62 | /** |
||
63 | * Add a remote file to the medialibrary. |
||
64 | * |
||
65 | * @param $url |
||
66 | * |
||
67 | * @return \Spatie\MediaLibrary\FileAdder\FileAdder |
||
68 | * |
||
69 | * @throws \Spatie\MediaLibrary\Exceptions\UrlCouldNotBeOpened |
||
70 | */ |
||
71 | public function addMediaFromUrl($url) |
||
87 | |||
88 | /** |
||
89 | * Copy a file to the medialibrary. |
||
90 | * |
||
91 | * @param string|\Symfony\Component\HttpFoundation\File\UploadedFile $file |
||
92 | * |
||
93 | * @return \Spatie\MediaLibrary\FileAdder\FileAdder |
||
94 | */ |
||
95 | public function copyMedia($file) |
||
99 | |||
100 | /** |
||
101 | * Determine if there is media in the given collection. |
||
102 | * |
||
103 | * @param $collectionName |
||
104 | * |
||
105 | * @return bool |
||
106 | */ |
||
107 | public function hasMedia($collectionName = '') |
||
111 | |||
112 | /** |
||
113 | * Get media collection by its collectionName. |
||
114 | * |
||
115 | * @param string $collectionName |
||
116 | * @param array $filters |
||
117 | * |
||
118 | * @return \Illuminate\Support\Collection |
||
119 | */ |
||
120 | public function getMedia($collectionName = '', $filters = []) |
||
124 | |||
125 | /** |
||
126 | * Get the first media item of a media collection. |
||
127 | * |
||
128 | * @param string $collectionName |
||
129 | * @param array $filters |
||
130 | * |
||
131 | * @return bool|Media |
||
132 | */ |
||
133 | public function getFirstMedia($collectionName = 'default', $filters = []) |
||
139 | |||
140 | /** |
||
141 | * Get the url of the image for the given conversionName |
||
142 | * for first media for the given collectionName. |
||
143 | * If no profile is given, return the source's url. |
||
144 | * |
||
145 | * @param string $collectionName |
||
146 | * @param string $conversionName |
||
147 | * |
||
148 | * @return string |
||
149 | */ |
||
150 | public function getFirstMediaUrl($collectionName = 'default', $conversionName = '') |
||
160 | |||
161 | /** |
||
162 | * Get the url of the image for the given conversionName |
||
163 | * for first media for the given collectionName. |
||
164 | * If no profile is given, return the source's url. |
||
165 | * |
||
166 | * @param string $collectionName |
||
167 | * @param string $conversionName |
||
168 | * |
||
169 | * @return string |
||
170 | */ |
||
171 | public function getFirstMediaPath($collectionName = 'default', $conversionName = '') |
||
181 | |||
182 | /** |
||
183 | * Update a media collection by deleting and inserting again with new values. |
||
184 | * |
||
185 | * @param array $newMediaArray |
||
186 | * @param string $collectionName |
||
187 | * |
||
188 | * @return array |
||
189 | * |
||
190 | * @throws \Spatie\MediaLibrary\Exceptions\MediaIsNotPartOfCollection |
||
191 | */ |
||
192 | public function updateMedia(array $newMediaArray, $collectionName = 'default') |
||
226 | |||
227 | /** |
||
228 | * @param array $newMediaArray |
||
229 | * @param string $collectionName |
||
230 | */ |
||
231 | protected function removeMediaItemsNotPresentInArray(array $newMediaArray, $collectionName = 'default') |
||
241 | |||
242 | /** |
||
243 | * Remove all media in the given collection. |
||
244 | * |
||
245 | * @param string $collectionName |
||
246 | * |
||
247 | * @return $this |
||
248 | */ |
||
249 | public function clearMediaCollection($collectionName = 'default') |
||
260 | |||
261 | /** |
||
262 | * Delete the associated media with the given id. |
||
263 | * You may also pass a media object. |
||
264 | * |
||
265 | * @param int|\Spatie\MediaLibrary\Media $mediaId |
||
266 | * |
||
267 | * @throws \Spatie\MediaLibrary\Exceptions\MediaDoesNotBelongToModel |
||
268 | */ |
||
269 | public function deleteMedia($mediaId) |
||
283 | |||
284 | /** |
||
285 | * Add a conversion. |
||
286 | * |
||
287 | * @param string $name |
||
288 | * |
||
289 | * @return \Spatie\MediaLibrary\Conversion\Conversion |
||
290 | */ |
||
291 | public function addMediaConversion($name) |
||
299 | |||
300 | /** |
||
301 | * Delete the model, but preserve all the associated media. |
||
302 | * |
||
303 | * @return bool |
||
304 | */ |
||
305 | public function deletePreservingMedia() |
||
311 | } |
||
312 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.