Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
ImageManager | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
upload | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
20 |
1 | <?php |
2 | |
3 | namespace App\Http\Helpers\FileManagement\S3; |
4 | |
5 | use Illuminate\Support\Facades\Validator; |
6 | |
7 | class ImageManager extends FileManager |
8 | { |
9 | private $maxSize = 52428800; |
10 | |
11 | public function upload($file, $public = true, $base64 = false) |
12 | { |
13 | if ($base64 && $file->getSize() <= $this->maxSize) { |
14 | return parent::upload($file, $public); |
15 | } |
16 | |
17 | $validator = Validator::make( |
18 | ['file' => $file], |
19 | ['file' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:'.$this->maxSize] |
20 | ); |
21 | |
22 | if ($validator->fails()) { |
23 | return [ |
24 | 'error' => 'The given data was invalid.', |
25 | 'error_list' => $validator->errors()->all(), |
26 | ]; |
27 | } |
28 | |
29 | return parent::upload($file, $public); |
30 | } |
31 | } |