I have this statement in my search function
if(!empty($project) && !empty($type)){
$result = Project::where('id', 'LIKE', "%{$project}%")->with(['type', function ($query) use ($type) {
$query->where('id', 'like', $type);
}])->get();
}
it returns
mb_strpos() expects parameter 1 to be string, object given
Logic
$project
=project.id
$type
=type.id
- If
$project and $ type
both have values then get project where id = $project - Then eager load
type
to that project where id = $type
is like we say types, where types.project_id = projects.id and where types.id = $type
but with eager load instead of query.
any idea?