Do you have an error ? Have you declared the relationship in the application model ?
Have you tried with whereHas() instead of with() ?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have two table 1. applications 2. users --applications-- table contains id,user_id,categroy,status | I want to filter applications table user name and also application column name
$applications = Application::with(['user'=>function($query) use ($request){
$query->where('name','like','%'.$request->name.'%');
}])->when($request->category,function ($query,$category){
return $query->where('category',$category);
})->paginate(10)->appends([
'name'=>$request->name,
'category'=>$request->category
]);
with relatinship query didn't work how to solve this issue?
Please or to participate in this conversation.