Add LikePipeline and like notifications
This commit is contained in:
parent
de9237b5e1
commit
3ec93d096c
4 changed files with 92 additions and 7 deletions
|
@ -5,21 +5,23 @@ namespace App\Http\Controllers;
|
|||
use Illuminate\Http\Request;
|
||||
use Auth, Hashids;
|
||||
use App\{Like, Profile, Status, User};
|
||||
use App\Jobs\LikePipeline\LikePipeline;
|
||||
|
||||
class LikeController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
if(Auth::check() === false) { abort(403); }
|
||||
$this->validate($request, [
|
||||
'item' => 'required|integer',
|
||||
]);
|
||||
|
||||
$statusId = $request->item;
|
||||
|
||||
$user = Auth::user();
|
||||
$profile = $user->profile;
|
||||
$status = Status::findOrFail($statusId);
|
||||
$profile = Auth::user()->profile;
|
||||
$status = Status::findOrFail($request->input('item'));
|
||||
|
||||
if($status->likes()->whereProfileId($profile->id)->count() !== 0) {
|
||||
$like = Like::whereProfileId($profile->id)->whereStatusId($status->id)->firstOrFail();
|
||||
|
@ -32,6 +34,8 @@ class LikeController extends Controller
|
|||
$like->status_id = $status->id;
|
||||
$like->save();
|
||||
|
||||
LikePipeline::dispatch($like);
|
||||
|
||||
return redirect($status->url());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue