mirror of https://github.com/pixelfed/pixelfed.git
Update LikeController
This commit is contained in:
parent
ea48792bf6
commit
9f928ae570
|
@ -32,20 +32,23 @@ class LikeController extends Controller
|
||||||
$like = Like::whereProfileId($profile->id)->whereStatusId($status->id)->firstOrFail();
|
$like = Like::whereProfileId($profile->id)->whereStatusId($status->id)->firstOrFail();
|
||||||
$like->forceDelete();
|
$like->forceDelete();
|
||||||
$count--;
|
$count--;
|
||||||
|
if($count >= 0) {
|
||||||
|
$status->likes_count = $count;
|
||||||
|
$status->save();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$like = new Like();
|
$like = new Like();
|
||||||
$like->profile_id = $profile->id;
|
$like->profile_id = $profile->id;
|
||||||
$like->status_id = $status->id;
|
$like->status_id = $status->id;
|
||||||
$like->save();
|
$like->save();
|
||||||
$count++;
|
$count++;
|
||||||
|
if($count >= 0) {
|
||||||
|
$status->likes_count = $count;
|
||||||
|
$status->save();
|
||||||
|
}
|
||||||
LikePipeline::dispatch($like);
|
LikePipeline::dispatch($like);
|
||||||
}
|
}
|
||||||
|
|
||||||
$likes = Like::whereProfileId($profile->id)
|
|
||||||
->orderBy('id', 'desc')
|
|
||||||
->take(1000)
|
|
||||||
->pluck('status_id');
|
|
||||||
|
|
||||||
if ($request->ajax()) {
|
if ($request->ajax()) {
|
||||||
$response = ['code' => 200, 'msg' => 'Like saved', 'count' => $count];
|
$response = ['code' => 200, 'msg' => 'Like saved', 'count' => $count];
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue