Update AvatarController

This commit is contained in:
Daniel Supernault 2019-03-01 14:02:05 -07:00
parent fca4562933
commit a2641dfc78
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -30,11 +30,10 @@ class AvatarController extends Controller
$dir = $path['root']; $dir = $path['root'];
$name = $path['name']; $name = $path['name'];
$public = $path['storage']; $public = $path['storage'];
$currentAvatar = storage_path('app/'.$profile->avatar->media_path);
$loc = $request->file('avatar')->storeAs($public, $name); $loc = $request->file('avatar')->storeAs($public, $name);
$avatar = Avatar::firstOrNew(['profile_id' => $profile->id]); $avatar = Avatar::firstOrNew(['profile_id' => $profile->id]);
$opath = $avatar->media_path; $currentAvatar = $avatar->recentlyCreated ? null : storage_path('app/'.$profile->avatar->media_path);
$avatar->media_path = "$public/$name"; $avatar->media_path = "$public/$name";
$avatar->thumb_path = null; $avatar->thumb_path = null;
$avatar->change_count = ++$avatar->change_count; $avatar->change_count = ++$avatar->change_count;