2021-07-02 07:33:49 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Observers;
|
|
|
|
|
|
|
|
use App\Like;
|
|
|
|
use App\Services\LikeService;
|
|
|
|
|
|
|
|
class LikeObserver
|
|
|
|
{
|
2022-09-27 05:58:15 +00:00
|
|
|
/**
|
|
|
|
* Handle events after all transactions are committed.
|
|
|
|
*
|
|
|
|
* @var bool
|
|
|
|
*/
|
|
|
|
public $afterCommit = true;
|
|
|
|
|
2021-07-02 07:33:49 +00:00
|
|
|
/**
|
|
|
|
* Handle the Like "created" event.
|
|
|
|
*
|
|
|
|
* @param \App\Models\Like $like
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function created(Like $like)
|
|
|
|
{
|
|
|
|
LikeService::add($like->profile_id, $like->status_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the Like "updated" event.
|
|
|
|
*
|
|
|
|
* @param \App\Models\Like $like
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function updated(Like $like)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the Like "deleted" event.
|
|
|
|
*
|
|
|
|
* @param \App\Models\Like $like
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function deleted(Like $like)
|
|
|
|
{
|
|
|
|
LikeService::remove($like->profile_id, $like->status_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the Like "restored" event.
|
|
|
|
*
|
|
|
|
* @param \App\Models\Like $like
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function restored(Like $like)
|
|
|
|
{
|
|
|
|
LikeService::add($like->profile_id, $like->status_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the Like "force deleted" event.
|
|
|
|
*
|
|
|
|
* @param \App\Models\Like $like
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function forceDeleted(Like $like)
|
|
|
|
{
|
|
|
|
LikeService::remove($like->profile_id, $like->status_id);
|
|
|
|
}
|
|
|
|
}
|