I want to display only the users who are admin and according to a search term which is entered in the searchbox
I store the keyword first
$keyword = $request->get('search');
and then
$users = User::with('admin')->where('role', 'super_admin')
->where(function ($query) use($keyword){
$query->where('id', 'LIKE', "%$keyword%")
->orWhere('name', 'LIKE', "%$keyword%");
})->paginate($perPage);
This works as im searching terms from main table that is user
table
But i also want to filter it using admin table columns as
$users = User::with('admin')->where('role', 'super_admin')
->where(function ($query) use($keyword){
$query->where('id', 'LIKE', "%$keyword%")
->orWhere('email', 'LIKE', "%$keyword%")
->orWhere('name', 'LIKE', "%$keyword%")
->orWhere($this->admin->status, 'LIKE', "%$keyword%");
})->paginate($perPage);
This throws an error undefined property admin
Due to this line ->orWhere($this->admin->status, 'LIKE', "%$keyword%");
So how can i use admin column in filtering data
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2Cg8JtV
via IFTTT
Aucun commentaire:
Enregistrer un commentaire