1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-25 01:05:36 +00:00

Update LikeController

This commit is contained in:
Daniel Supernault 2020-03-20 21:17:14 -06:00
parent 01525cba4c
commit 3a828522dd
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -25,7 +25,7 @@ class LikeController extends Controller
$user = Auth::user();
$profile = $user->profile;
$status = Status::withCount('likes')->findOrFail($request->input('item'));
$status = Status::findOrFail($request->input('item'));
$count = $status->likes_count;
@ -36,14 +36,16 @@ class LikeController extends Controller
$status->likes_count = $count;
$status->save();
} else {
$like = new Like();
$like->profile_id = $profile->id;
$like->status_id = $status->id;
$like->save();
$count++;
$status->likes_count = $count;
$status->save();
LikePipeline::dispatch($like);
$like = Like::firstOrCreate([
'profile_id' => $user->profile_id,
'status_id' => $status->id
]);
if($like->wasRecentlyCreated == true) {
$count++;
$status->likes_count = $count;
$status->save();
LikePipeline::dispatch($like);
}
}
Cache::forget('status:'.$status->id.':likedby:userid:'.$user->id);