1 | <?php |
||
17 | class Media extends Model |
||
18 | { |
||
19 | use SortableTrait; |
||
20 | |||
21 | const TYPE_OTHER = 'other'; |
||
22 | const TYPE_IMAGE = 'image'; |
||
23 | const TYPE_VIDEO = 'video'; |
||
24 | const TYPE_SVG = 'svg'; |
||
25 | const TYPE_PDF = 'pdf'; |
||
26 | |||
27 | protected $guarded = ['id', 'disk', 'file_name', 'size', 'model_type', 'model_id']; |
||
28 | |||
29 | /** |
||
30 | * The attributes that should be casted to native types. |
||
31 | * |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $casts = [ |
||
35 | 'manipulations' => 'array', |
||
36 | 'custom_properties' => 'array', |
||
37 | ]; |
||
38 | |||
39 | /** |
||
40 | * Create the polymorphic relation. |
||
41 | * |
||
42 | * @return \Illuminate\Database\Eloquent\Relations\MorphTo |
||
43 | */ |
||
44 | public function model() |
||
48 | |||
49 | /** |
||
50 | * Get the original Url to a media-file. |
||
51 | * |
||
52 | * @param string $conversionName |
||
53 | * |
||
54 | * @return string |
||
55 | * |
||
56 | * @throws \Spatie\MediaLibrary\Exceptions\InvalidConversion |
||
57 | */ |
||
58 | public function getUrl(string $conversionName = '') : string |
||
68 | |||
69 | /** |
||
70 | * Get the original path to a media-file. |
||
71 | * |
||
72 | * @param string $conversionName |
||
73 | * |
||
74 | * @return string |
||
75 | * |
||
76 | * @throws \Spatie\MediaLibrary\Exceptions\InvalidConversion |
||
77 | */ |
||
78 | public function getPath(string $conversionName = '') : string |
||
88 | |||
89 | /** |
||
90 | * Collection of all ImageGenerator drivers. |
||
91 | */ |
||
92 | public function getImageGenerators() : Collection |
||
101 | |||
102 | /** |
||
103 | * Determine the type of a file. |
||
104 | * |
||
105 | * @return string |
||
106 | */ |
||
107 | public function getTypeAttribute() |
||
116 | |||
117 | /** |
||
118 | * Determine the type of a file from its file extension. |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | public function getTypeFromExtensionAttribute() |
||
137 | |||
138 | /* |
||
139 | * Determine the type of a file from its mime type |
||
140 | */ |
||
141 | public function getTypeFromMimeAttribute() : string |
||
160 | |||
161 | public function getMimeAttribute() : string |
||
165 | |||
166 | public function getExtensionAttribute() : string |
||
170 | |||
171 | public function getHumanReadableSizeAttribute() : string |
||
175 | |||
176 | public function getDiskDriverName() : string |
||
180 | |||
181 | /* |
||
182 | * Determine if the media item has a custom property with the given name. |
||
183 | */ |
||
184 | public function hasCustomProperty(string $propertyName) : bool |
||
188 | |||
189 | /** |
||
190 | * Get if the value of custom property with the given name. |
||
191 | * |
||
192 | * @param string $propertyName |
||
193 | * @param mixed $default |
||
194 | * |
||
195 | * @return mixed |
||
196 | */ |
||
197 | public function getCustomProperty(string $propertyName, $default = null) |
||
201 | |||
202 | /** |
||
203 | * @param string $name |
||
204 | * @param mixed $value |
||
205 | */ |
||
206 | public function setCustomProperty(string $name, $value) |
||
210 | |||
211 | /** |
||
212 | * @param string $name |
||
213 | * |
||
214 | * @return $this |
||
215 | */ |
||
216 | public function removeCustomProperty(string $name) |
||
228 | |||
229 | /* |
||
230 | * Get all the names of the registered media conversions. |
||
231 | */ |
||
232 | public function getMediaConversionNames() : array |
||
240 | } |
||
241 |