1 | <?php |
||
2 | |||
3 | namespace WebDevEtc\BlogEtc\Requests\Traits; |
||
4 | |||
5 | use Illuminate\Http\UploadedFile; |
||
6 | |||
7 | trait HasImageUploadTrait |
||
8 | { |
||
9 | /** |
||
10 | * @param $size |
||
11 | * |
||
12 | * @return UploadedFile|null |
||
13 | */ |
||
14 | public function get_image_file($size) |
||
15 | { |
||
16 | if ($this->file($size)) { |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
17 | return $this->file($size); |
||
18 | } |
||
19 | |||
20 | // not found? lets cycle through all the images and see if anything was submitted, and use that instead |
||
21 | foreach (config('blogetc.image_sizes') as $image_size_name => $image_size_info) { |
||
22 | if ($this->file($image_size_name)) { |
||
23 | return $this->file($image_size_name); |
||
24 | } |
||
25 | } |
||
26 | } |
||
27 | } |
||
28 |