Level 1
i can achieve this with which i don't want
whereHas('roles',function($q)use($array){
$q->whereIn('name',$array);
})
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
how to query value as a type of array for query whereRelation eloquent relation
https://github.com/laravel/framework/blob/9.x/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php
public function whereRelation($relation, $column, $operator = null, $value = null)
{
return $this->whereHas($relation, function ($query) use ($column, $operator, $value) {
if ($column instanceof Closure) {
$column($query);
} else {
$query->where($column, $operator, $value);
}
});
}
I want to query with value as a type of array
\App\Models\User::whereRelation('roles','name',null,['admin','editor'])->get()
how can I achieve this
Please or to participate in this conversation.