mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-30 16:30:45 +00:00
Update LikeController
This commit is contained in:
parent
01525cba4c
commit
3a828522dd
1 changed files with 11 additions and 9 deletions
|
@ -25,7 +25,7 @@ class LikeController extends Controller
|
||||||
|
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
$profile = $user->profile;
|
$profile = $user->profile;
|
||||||
$status = Status::withCount('likes')->findOrFail($request->input('item'));
|
$status = Status::findOrFail($request->input('item'));
|
||||||
|
|
||||||
$count = $status->likes_count;
|
$count = $status->likes_count;
|
||||||
|
|
||||||
|
@ -36,14 +36,16 @@ class LikeController extends Controller
|
||||||
$status->likes_count = $count;
|
$status->likes_count = $count;
|
||||||
$status->save();
|
$status->save();
|
||||||
} else {
|
} else {
|
||||||
$like = new Like();
|
$like = Like::firstOrCreate([
|
||||||
$like->profile_id = $profile->id;
|
'profile_id' => $user->profile_id,
|
||||||
$like->status_id = $status->id;
|
'status_id' => $status->id
|
||||||
$like->save();
|
]);
|
||||||
$count++;
|
if($like->wasRecentlyCreated == true) {
|
||||||
$status->likes_count = $count;
|
$count++;
|
||||||
$status->save();
|
$status->likes_count = $count;
|
||||||
LikePipeline::dispatch($like);
|
$status->save();
|
||||||
|
LikePipeline::dispatch($like);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Cache::forget('status:'.$status->id.':likedby:userid:'.$user->id);
|
Cache::forget('status:'.$status->id.':likedby:userid:'.$user->id);
|
||||||
|
|
Loading…
Reference in a new issue