1 | <?php |
||
12 | class Media extends Model |
||
13 | { |
||
14 | use SortableTrait; |
||
15 | |||
16 | const TYPE_OTHER = 'other'; |
||
17 | |||
18 | protected $guarded = []; |
||
19 | |||
20 | /** |
||
21 | * The attributes that should be casted to native types. |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $casts = [ |
||
26 | 'manipulations' => 'array', |
||
27 | 'custom_properties' => 'array', |
||
28 | ]; |
||
29 | |||
30 | /** |
||
31 | * Create the polymorphic relation. |
||
32 | * |
||
33 | * @return \Illuminate\Database\Eloquent\Relations\MorphTo |
||
34 | */ |
||
35 | public function model() |
||
39 | |||
40 | /** |
||
41 | * Get the full url to a original media file. |
||
42 | * |
||
43 | * @param string $conversionName |
||
44 | * |
||
45 | * @return string |
||
46 | * |
||
47 | * @throws \Spatie\MediaLibrary\Exceptions\InvalidConversion |
||
48 | */ |
||
49 | public function getFullUrl(string $conversionName = ''): string |
||
53 | |||
54 | /** |
||
55 | * Get the url to a original media file. |
||
56 | * |
||
57 | * @param string $conversionName |
||
58 | * |
||
59 | * @return string |
||
60 | * |
||
61 | * @throws \Spatie\MediaLibrary\Exceptions\InvalidConversion |
||
62 | */ |
||
63 | public function getUrl(string $conversionName = ''): string |
||
75 | |||
76 | /** |
||
77 | * Get the path to the original media file. |
||
78 | * |
||
79 | * @param string $conversionName |
||
80 | * |
||
81 | * @return string |
||
82 | * |
||
83 | * @throws \Spatie\MediaLibrary\Exceptions\InvalidConversion |
||
84 | */ |
||
85 | public function getPath(string $conversionName = ''): string |
||
97 | |||
98 | /** |
||
99 | * Collection of all ImageGenerator drivers. |
||
100 | */ |
||
101 | public function getImageGenerators() : Collection |
||
105 | |||
106 | /** |
||
107 | * Determine the type of a file. |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | public function getTypeAttribute() |
||
121 | |||
122 | public function getTypeFromExtension(): string |
||
134 | |||
135 | /* |
||
136 | * Determine the type of a file from its mime type |
||
137 | */ |
||
138 | public function getTypeFromMime(): string |
||
150 | |||
151 | public function getExtensionAttribute(): string |
||
155 | |||
156 | public function getHumanReadableSizeAttribute(): string |
||
160 | |||
161 | public function getDiskDriverName(): string |
||
165 | |||
166 | /* |
||
167 | * Determine if the media item has a custom property with the given name. |
||
168 | */ |
||
169 | public function hasCustomProperty(string $propertyName): bool |
||
173 | |||
174 | /** |
||
175 | * Get if the value of custom property with the given name. |
||
176 | * |
||
177 | * @param string $propertyName |
||
178 | * @param mixed $default |
||
179 | * |
||
180 | * @return mixed |
||
181 | */ |
||
182 | public function getCustomProperty(string $propertyName, $default = null) |
||
186 | |||
187 | /** |
||
188 | * @param string $name |
||
189 | * @param mixed $value |
||
190 | * |
||
191 | * @return $this |
||
192 | */ |
||
193 | public function setCustomProperty(string $name, $value) |
||
203 | |||
204 | /** |
||
205 | * @param string $name |
||
206 | * |
||
207 | * @return $this |
||
208 | */ |
||
209 | public function forgetCustomProperty(string $name) |
||
219 | |||
220 | /* |
||
221 | * Get all the names of the registered media conversions. |
||
222 | */ |
||
223 | public function getMediaConversionNames(): array |
||
231 | } |
||
232 |