diff options
Diffstat (limited to 'app/Http/Controllers/ImageController.php')
-rw-r--r-- | app/Http/Controllers/ImageController.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/app/Http/Controllers/ImageController.php b/app/Http/Controllers/ImageController.php new file mode 100644 index 0000000..37874f5 --- /dev/null +++ b/app/Http/Controllers/ImageController.php @@ -0,0 +1,28 @@ +<?php + +namespace App\Http\Controllers; + +use Illuminate\Http\Request; +use Illuminate\Foundation\Auth\User; +use Intervention\Image\ImageManagerStatic as Image; + +class ImageController extends Controller +{ + public function getAvatar($user_id) + { + $usersAvatar = User::findOrFail($user_id)->avatar; + $storagePath = storage_path('app/public/avatars/' . $usersAvatar); + return Image::make($storagePath)->resize(100, 100)->response(); + + // $request->validate([ + // 'avatar' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048', + // ]); + // $user = Auth::user(); + // $avatarName = $user->id . '_avatar_' . time() . '.' . request()->avatar->getClientOriginalExtension(); + // $request->avatar->storeAs('avatars', $avatarName); + // $user->avatar = $avatarName; + // $user->save(); + // return back() + // ->with('success', 'You have successfully upload image.'); + } +} |