What problem?
by the way. you have a return statement inside your foreach loop so it will only ever execute one loop
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
how i can fix this error
Image source not readable
filesystem.php
'myDriver' => [
'driver' => 'local',
'root' => public_path(),
'visibility' => 'public',
],
static $sizes = [300 , 600 , 900];
public function uploadImage($values, $article)
{
if ($values->hasFile('images')) {
foreach ($values->images as $image) {
$filename = $image->getClientOriginalName();
$dir = 'images/article';
$path = $image->store($dir, 'myDriver');
$article->images()->create([
'filename' => $filename,
'path' => $path
]);
return self::resize(Storage::path($path), $dir, $filename);
}
}
}
public static function resize($img , $dir , $filename)
{
$img = Image::make($img);
$images['original'] = $filename;
foreach (self::$sizes as $size) {
$images[$size] = $size . '_' . $filename;
$img->resize($size , null , function($aspect){
$aspect->aspectRatio();
})->save(Storage::path($dir).'_'.$size.'.'.$filename);
}
return $images;
}
Please or to participate in this conversation.