xoco70 /
kendozone
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace App\Http\Controllers; |
||||
| 4 | |||||
| 5 | |||||
| 6 | use Intervention\Image\Facades\Image; |
||||
| 7 | |||||
| 8 | class UserAvatarController extends Controller |
||||
| 9 | { |
||||
| 10 | /** |
||||
| 11 | * Store a newly created resource in storage. |
||||
| 12 | * |
||||
| 13 | */ |
||||
| 14 | 1 | public function store() |
|||
| 15 | { |
||||
| 16 | 1 | request()->validate([ |
|||
| 17 | 1 | 'file' => ['required', 'image'] |
|||
| 18 | ]); |
||||
| 19 | $file = request() |
||||
| 20 | ->file('file') |
||||
| 21 | ->store(config('constants.RELATIVE_AVATAR_PATH'), 'public'); |
||||
| 22 | |||||
| 23 | Image::make(storage_path('app/public/' . $file)) |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 24 | ->resize(200, 200, function ($constraint) { |
||||
| 25 | $constraint->aspectRatio(); |
||||
| 26 | $constraint->upsize(); |
||||
| 27 | }) |
||||
| 28 | ->save(); |
||||
| 29 | |||||
| 30 | auth()->user()->update([ |
||||
| 31 | 'avatar' => basename($file) |
||||
|
0 ignored issues
–
show
It seems like
$file can also be of type false; however, parameter $path of basename() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 32 | ]); |
||||
| 33 | return response([], 204); |
||||
| 34 | } |
||||
| 35 | } |
||||
| 36 |