1 | <?php |
||
2 | |||
3 | |||
4 | namespace Larapie\Actions\Attributes\Rules; |
||
5 | |||
6 | |||
7 | trait FileRules |
||
8 | { |
||
9 | public function image() |
||
10 | { |
||
11 | return $this->rule('image'); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
12 | } |
||
13 | |||
14 | /* |
||
15 | * Define dimensions with the properties as specified in the laravel documentation but in a kay value array |
||
16 | * e.g. ["max_height" => 50] |
||
17 | */ |
||
18 | public function dimensions(array $dimensions) |
||
19 | { |
||
20 | $dimensions = collect($dimensions) |
||
21 | ->map(function ($key, $value) { |
||
22 | return "$key=$value"; |
||
23 | }) |
||
24 | ->implode(',', ''); |
||
25 | |||
26 | return $this->rule('mimes:' . $dimensions); |
||
27 | } |
||
28 | |||
29 | public function mimes(string ...$extensions) |
||
30 | { |
||
31 | return $this->rule('mimes:' . implode(',', $extensions)); |
||
32 | } |
||
33 | |||
34 | public function mimeTypes(string ...$types) |
||
35 | { |
||
36 | return $this->rule('mimetypes:' . implode(',', $types)); |
||
37 | } |
||
38 | |||
39 | public function size(int $size) |
||
40 | { |
||
41 | return $this->rule("size:$size"); |
||
42 | } |
||
43 | } |