diff options
author | Marvin Borner | 2018-07-01 12:45:00 +0200 |
---|---|---|
committer | Marvin Borner | 2018-07-01 12:45:00 +0200 |
commit | aa73af3be51f6e36ea9ea5a1f78ac18c0b2a352c (patch) | |
tree | 3886430ea25457ca4ee72cb26d3f0c0740957dcb /app/Http | |
parent | e7307d3241fb1f31a10ef92565c17b224d5983f0 (diff) |
Better avatar requests
Diffstat (limited to 'app/Http')
-rw-r--r-- | app/Http/Controllers/ImageController.php | 28 | ||||
-rw-r--r-- | app/Http/Controllers/UserController.php | 2 |
2 files changed, 29 insertions, 1 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.'); + } +} diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 1e2b204..42f4e16 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -24,6 +24,6 @@ class UserController extends Controller $user->avatar = $avatarName; $user->save(); return back() - ->with('success', 'You have successfully upload image.'); + ->with('success', 'You have successfully uploaded the avatar.'); } } |