Add a concat to search for full name when the relationship search in the users table

This commit is contained in:
Ivan Nieto Vivanco 2022-08-10 18:27:28 -05:00
parent c39bf7b7e6
commit c1074000f9

View file

@ -2,6 +2,7 @@
namespace App\Models\Traits;
use DB;
use App\Models\Asset;
use App\Models\CustomField;
use Illuminate\Database\Eloquent\Builder;
@ -160,6 +161,9 @@ trait Searchable
}
$query->orWhere($table.'.'.$column, 'LIKE', '%'.$term.'%');
if($table == 'users'){
$query->orWhereRaw('CONCAT(users.first_name ," ", users.last_name) LIKE ?', ["%$term%"]);
}
}
}
});