image){ File::delete($this->image); File::delete($this->thumbnail); } $valueName = pathinfo($value->getClientOriginalName(), PATHINFO_FILENAME); $extension = pathinfo($value->getClientOriginalName(), PATHINFO_EXTENSION); $newFileName = md5($valueName.time()).'.'.$extension; $img = Image::make($value->getRealPath()); $img->resize(1200, 1200, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); }); $img->save($destinationPath.'images/'.$newFileName); $img->fit(370, 500); $img->save($destinationPath.'thumbnails/'.$newFileName); $this->attributes['image'] = $destinationPath.'images/'.$newFileName; $this->attributes['thumbnail'] = $destinationPath.'thumbnails/'.$newFileName; } } }