Class OptimizerChain
NOT found
#145
Answered
by
mahmoudmohamedramadan
mahmoudmohamedramadan
asked this question in
Q&A
-
Hi 👋, in use Spatie\ImageOptimizer\OptimizerChainFactory;
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\Models\User
*/
protected function create(array $data)
{
if (request()->hasFile('avatar')) {
/* store uploaded file, then get the image path */
$uploadedImage = request()->file('avatar')->store('public/users');
/* get instance from `OptimizerChainFactory::class` then pass the $uploadedImage to `omptimize()` method */
$optimizerChain = OptimizerChainFactory::create();
$imagePath = asset("storage/users/{$uploadedImage}");
$optimizerChain->optimize($imagePath);
/* get the image's hash name WITH its extension */
$data['avatar'] = Str::after($uploadedImage, '/users/');
}
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'avatar' => $data['avatar'],
'password' => Hash::make($data['password']),
]);
} the data of the user was saved, the uploaded image was stored successfully also, BUT after I've installed this package, this ERROR |
Beta Was this translation helpful? Give feedback.
Answered by
mahmoudmohamedramadan
Jun 26, 2021
Replies: 1 comment
-
The issue is solved via run the NEXT command
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mahmoudmohamedramadan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The issue is solved via run the NEXT command