Load Limit Filter Limit in Laravel

I cannot filter the contents of the groups table against the username in the users table using Unwanted load limits

 public function username() { return $this->belongsTo('User','fk_users_id')->select(['id','username']); } 

I tried using the code below, but it only filters users data, not groups data

 $groups = Groups::with(array('username' => function($query) use ($keyword) { $query->where('username', 'like', '%'.$keyword.'%'); })) ->where('status',1)->paginate($paginateValue); 

any help is appreciated ...

+2
source share
1 answer

Think it should be something like this:

 Groups::with('User')->whereHas('User', function($q) use ($key){ $q->where('username', 'like', '%'.$key.'%'); })->where('status', 1)->paginate($pagVal); 
0
source

Source: https://habr.com/ru/post/979174/


All Articles