for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace CSlant\LaravelLike\Traits\Like;
use CSlant\LaravelLike\Enums\InteractionTypeEnum;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\Relations\MorphOne;
/**
* Trait LikeScopes
*
* @package CSlant\LaravelLike\Traits\Like
* @mixin Model
* @method MorphOne likeOne()
* @method MorphMany likes()
*/
trait LikeScopes
{
* The scope locale for select like relationship with the model (one).
* @return MorphOne
public function likeTo(): MorphOne
return $this->likeOne()->where('type', InteractionTypeEnum::LIKE);
}
* The scope locale for select dislike relationship with the model (one).
public function dislikeTo(): MorphOne
return $this->likeOne()->where('type', InteractionTypeEnum::DISLIKE);
* The scope locale for select likes relationship (all).
* @return MorphMany
public function likesTo(): MorphMany
return $this->likes()->where('type', InteractionTypeEnum::LIKE);
* The scope locale for select dislikes relationship (all).
public function dislikesTo(): MorphMany
return $this->likes()->where('type', InteractionTypeEnum::DISLIKE);