1 | <?php |
||
14 | class Media extends Model implements Responsable |
||
15 | { |
||
16 | use SortableTrait; |
||
17 | |||
18 | const TYPE_OTHER = 'other'; |
||
19 | |||
20 | protected $guarded = []; |
||
21 | |||
22 | /** |
||
23 | * The attributes that should be casted to native types. |
||
24 | * |
||
25 | * @var array |
||
26 | */ |
||
27 | protected $casts = [ |
||
28 | 'manipulations' => 'array', |
||
29 | 'custom_properties' => 'array', |
||
30 | ]; |
||
31 | |||
32 | /** |
||
33 | * Create the polymorphic relation. |
||
34 | * |
||
35 | * @return \Illuminate\Database\Eloquent\Relations\MorphTo |
||
36 | */ |
||
37 | public function model() |
||
41 | |||
42 | /** |
||
43 | * Get the full url to a original media file. |
||
44 | * |
||
45 | * @param string $conversionName |
||
46 | * |
||
47 | * @return string |
||
48 | * |
||
49 | * @throws \Spatie\MediaLibrary\Exceptions\InvalidConversion |
||
50 | */ |
||
51 | public function getFullUrl(string $conversionName = ''): string |
||
55 | |||
56 | /** |
||
57 | * Get the url to a original media file. |
||
58 | * |
||
59 | * @param string $conversionName |
||
60 | * |
||
61 | * @return string |
||
62 | * |
||
63 | * @throws \Spatie\MediaLibrary\Exceptions\InvalidConversion |
||
64 | */ |
||
65 | public function getUrl(string $conversionName = ''): string |
||
71 | |||
72 | public function getTemporaryUrl(DateTimeInterface $expiration, string $conversionName = '', array $options = []): string |
||
78 | |||
79 | /** |
||
80 | * Get the path to the original media file. |
||
81 | * |
||
82 | * @param string $conversionName |
||
83 | * |
||
84 | * @return string |
||
85 | * |
||
86 | * @throws \Spatie\MediaLibrary\Exceptions\InvalidConversion |
||
87 | */ |
||
88 | public function getPath(string $conversionName = ''): string |
||
94 | |||
95 | /** |
||
96 | * Collection of all ImageGenerator drivers. |
||
97 | */ |
||
98 | public function getImageGenerators() : Collection |
||
102 | |||
103 | /** |
||
104 | * Determine the type of a file. |
||
105 | * |
||
106 | * @return string |
||
107 | */ |
||
108 | public function getTypeAttribute() |
||
118 | |||
119 | public function getTypeFromExtension(): string |
||
131 | |||
132 | /* |
||
133 | * Determine the type of a file from its mime type |
||
134 | */ |
||
135 | public function getTypeFromMime(): string |
||
147 | |||
148 | public function getExtensionAttribute(): string |
||
152 | |||
153 | public function getHumanReadableSizeAttribute(): string |
||
157 | |||
158 | public function getDiskDriverName(): string |
||
162 | |||
163 | /* |
||
164 | * Determine if the media item has a custom property with the given name. |
||
165 | */ |
||
166 | public function hasCustomProperty(string $propertyName): bool |
||
170 | |||
171 | /** |
||
172 | * Get if the value of custom property with the given name. |
||
173 | * |
||
174 | * @param string $propertyName |
||
175 | * @param mixed $default |
||
176 | * |
||
177 | * @return mixed |
||
178 | */ |
||
179 | public function getCustomProperty(string $propertyName, $default = null) |
||
183 | |||
184 | /** |
||
185 | * @param string $name |
||
186 | * @param mixed $value |
||
187 | * |
||
188 | * @return $this |
||
189 | */ |
||
190 | public function setCustomProperty(string $name, $value) |
||
200 | |||
201 | /** |
||
202 | * @param string $name |
||
203 | * |
||
204 | * @return $this |
||
205 | */ |
||
206 | public function forgetCustomProperty(string $name) |
||
216 | |||
217 | /* |
||
218 | * Get all the names of the registered media conversions. |
||
219 | */ |
||
220 | public function getMediaConversionNames(): array |
||
228 | |||
229 | /** |
||
230 | * Create an HTTP response that represents the object. |
||
231 | * |
||
232 | * @param \Illuminate\Http\Request $request |
||
233 | * @return \Illuminate\Http\Response |
||
234 | */ |
||
235 | public function toResponse($request) |
||
240 | } |
||
241 |