for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Containers\User\Data\Criterias;
use App\Port\Criteria\Abstracts\Criteria;
use Prettus\Repository\Contracts\RepositoryInterface as PrettusRepositoryInterface;
/**
* Class RoleCriteria.
*
* @author Mahmoud Zalt <[email protected]>
*/
class RoleCriteria extends Criteria
{
* @var string
private $roles;
* RoleCriteria constructor.
* @param $roles
public function __construct($roles)
$this->roles = $roles;
}
* @param $model
* @param \Prettus\Repository\Contracts\RepositoryInterface $repository
* @return mixed
public function apply($model, PrettusRepositoryInterface $repository)
return $model->whereHas('roles', function ($q) {
$q->where('name', $this->roles);
});