Мой код работает нормально, но, несмотря на то, что он возвращает роль пользователя в ответе, могу ли я предотвратить возвращение ролей пользователя, которые принадлежат отношению с использованием role_id в таблицах пользователей Таблица
$paths = Path::with(['user','tags'])->where('category_id',1)->get();
foreach($paths as $path){
if($path->user->hasRole('admin')){
$AdminPaths [] = $path;
}
if($path->user->hasRole('user')){
$UserPaths [] = $path;
}
}
return $UserPaths;
Моя модель пользователя
class User extends \TCG\Voyager\Models\User
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'username'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}