Update AvatarController, remove deprecated thumb_path

This commit is contained in:
Daniel Supernault 2021-01-24 18:22:13 -07:00
parent 1e9958f521
commit 889c3d8758
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
5 changed files with 1 additions and 20 deletions

View file

@ -183,7 +183,6 @@ class BaseApiController extends Controller
$avatar = Avatar::whereProfileId($profile->id)->firstOrFail();
$opath = $avatar->media_path;
$avatar->media_path = "$public/$name";
$avatar->thumb_path = null;
$avatar->change_count = ++$avatar->change_count;
$avatar->last_processed_at = null;
$avatar->save();

View file

@ -35,7 +35,6 @@ class AvatarController extends Controller
$avatar = Avatar::firstOrNew(['profile_id' => $profile->id]);
$currentAvatar = $avatar->recentlyCreated ? null : storage_path('app/'.$profile->avatar->media_path);
$avatar->media_path = "$public/$name";
$avatar->thumb_path = null;
$avatar->change_count = ++$avatar->change_count;
$avatar->last_processed_at = null;
$avatar->save();
@ -121,10 +120,7 @@ class AvatarController extends Controller
$avatar = $profile->avatar;
if( $avatar->media_path == 'public/avatars/default.png' ||
$avatar->thumb_path == 'public/avatars/default.png' ||
$avatar->media_path == 'public/avatars/default.jpg' ||
$avatar->thumb_path == 'public/avatars/default.jpg'
$avatar->media_path == 'public/avatars/default.jpg'
) {
return;
}
@ -133,12 +129,7 @@ class AvatarController extends Controller
@unlink(storage_path('app/' . $avatar->media_path));
}
if(is_file(storage_path('app/' . $avatar->thumb_path))) {
@unlink(storage_path('app/' . $avatar->thumb_path));
}
$avatar->media_path = 'public/avatars/default.jpg';
$avatar->thumb_path = 'public/avatars/default.jpg';
$avatar->change_count = $avatar->change_count + 1;
$avatar->save();

View file

@ -58,7 +58,6 @@ class AvatarOptimize implements ShouldQueue
$img->save($file, $quality);
$avatar = Avatar::whereProfileId($this->profile->id)->firstOrFail();
$avatar->thumb_path = $avatar->media_path;
$avatar->change_count = ++$avatar->change_count;
$avatar->last_processed_at = Carbon::now();
$avatar->save();

View file

@ -45,7 +45,6 @@ class CreateAvatar implements ShouldQueue
$avatar = new Avatar();
$avatar->profile_id = $profile->id;
$avatar->media_path = $path;
$avatar->thumb_path = $path;
$avatar->change_count = 0;
$avatar->last_processed_at = \Carbon\Carbon::now();
$avatar->save();

View file

@ -54,13 +54,6 @@ class AvatarObserver
) {
@unlink($path);
}
$path = storage_path('app/'.$avatar->thumb_path);
if( is_file($path) &&
$avatar->thumb_path != 'public/avatars/default.png' &&
$avatar->media_path != 'public/avatars/default.jpg'
) {
@unlink($path);
}
}
/**