Category : filter

I have the following alerts in my project : Alerts: I want when I click on a specific alert , it shows me only the line of that alert. I have the following code which displays the alerts: <div class="card-body"> <h5 class="card-title">Contrats à renouveller</h5> <div class="scroll dashboard-list-with-thumbs"> @foreach($contrats_expires as $contrat_expires) <div class="d-flex flex-row mb-3"> <a ..

Read more

We are getting latitude and longitude on 3rd level due to which the filter in below query is not working in Laravel //Filters Form Nearest location with latitude and longitude. `if($request->latitude !="" && $request->longitude !="") { $list = $list->whereHas(‘partnerOutletPromotion’, function ($query) use ($request) { $query->select(DB::raw("*, 6371 * acos(cos(radians(‘".$request->latitude."’)) * cos(radians(latitude)) * cos(radians(longitude) – radians(‘".$request->longitude."’)) + ..

Read more

Developers, I am working on a report that I have to display the companies ranking based on some conditions for the date range which comes from front. Ex: last week, I have done that, but now I want to show how many weeks that a particular company be in same rank. If I am checking ..

Read more

Background first on my question. A user hasMany contacts and a contact hasMany anniversaries. I want to filter the upcoming anniversaries. So far I have this: $filtered = auth()->user()->contacts()->get()->each(function ($contact) { $contact->anniversaries->filter(function ($anniversary) { // return true or false based on a method on the anniversary model return $anniversary->method() == true; }); }); But this ..

Read more

Someone recommended me using spatie/laravel-query-builder for filtering/searching data when I ask about how to filter data that had relationship. I’m still confused by it. What I’m trying to do: filter/search data with roles of ‘Student'(relationship) and contain the ‘x’ word. mycontroller.php before adding any spatie/query-builder code public function searchStudent(Request $request) { $user = Auth::user(); // ..

Read more

I have a page that displays all the records from the ‘Receita’ table like this: public function mostrarTodos() { $receitas = Receita::all()->toArray(); $ingredientes = Ingrediente::all()->toArray(); return view(‘home’, compact(‘receitas’, ‘ingredientes’)); } on the top of the page there is a form with many checkboxes that will filter the results displayed on the front page: <div class="col-span-2 ..

Read more

I have a problem with filtering datatable through relationships. I have a table with the main model with the various relationships and I need to filter concatenated name and surname It doesn’t came out any error but does not find any results Controller: $data = Repair::with(‘clients’,’categories’,’brands’,’modells’,’typeRepairs’,’states’,’stateClients’) ->select("*"); return Datatables::of($data) ->addIndexColumn() ->filterColumn(‘nomecognome’, function($query, $keyword) { $query->whereHas("clients", ..

Read more

I have 3 tables: User, Role and the pivot table RoleUser with role_id and user_id. For the relations in my models i did that : Role Model : public function users() { return $this->belongsToMany(‘AppModelsUser’)->using(RoleUser::class); } User Model: public function roles() { return $this->hasMany(‘AppModelsRole’)->using(RoleUser::class); } I did that for filter by one role and it works ..

Read more

I have a form that looks like below. I have three "white" dropdowns to filter the value for the Equipment Registration Tag dropdown ( The values of dropdown input field that has Equipment Registration Tag label will only come out after user select values for the three "white" dropdowns). So the Equipment Registration Tag values ..

Read more

foreach ($this->data as $row) { $year = $row[$dataPositions[‘year’]]; $name = $row[$dataPositions[‘name’]]; $foundgames = &$this->foundgames; $game = $games->first(function($game, $key) use ($year, $name) { if ( $year === $game->year && $game->name === $name ) { return true; } }); if ($game) { $game->number = $number; $game->catalog_name = $name; $this->foundgames[] = $game; $games = $games->filter(function($gam) use ($game) { ..

Read more

I have this code in controller : $myresults = $matches->map(function ($items, $key ) { $items[‘date’]=CarbonCarbon::parse($items[‘m_date’])->format("Y-m-d"); $items[‘time’]=CarbonCarbon::parse($items[‘m_date’])->format("H:i"); return $items; })->groupBy(function ($item, $key) { return CarbonCarbon::parse($item["date"])->format("Y-m-d"); })->map(function ($item, $key) { return ["date"=> $key, "matches"=> $item]; })->values(); $results = collect($myresults)->filter(fn ($item)=> collect($item[‘matches’])->filter(fn ($match)=> collect($match[‘predect’])->filter(fn ($predect)=> $predect[‘user_id’]!=$id))); it works before fine ,after I deploy it to website it gaves ..

Read more

I want to refactor my source code when filtering records in all and specific fields. Currently, I’m filtering all fields by passing ‘search’ in my request: GET request: /api/users?search= public function index(Request $request) { $search = request("search") ?? ""; $users = $users->where(function ($query) use ($search) { $query->where(‘code’, "like", "%" . $search . "%"); $query->orWhere("first_name", "like", ..

Read more

I want to search data from database and show in my laravel blade. here is my controller $results = ClassModel::query(); $results->when(request(‘student_id’), function($q){ $q->where(‘student_id’, request(‘student_id’)); }); $results->when(request(‘student_name’),function($q){ $q->where(‘student_name’, request(‘student_name’)); }); $results->when(request(‘subject’), function($q){ $q->where(‘subject’, request(‘subject’)); }); $results->when(request(‘teacher_name’), function($q){ $q->where(‘teacher_name’, request(‘teacher_name’)); }); $results->when(request(‘class’), function($q){ $q->where(‘class’, request(‘class’)); }); $records = $results->get(); return view(‘class.index’)->with(‘class’, $records); it works ok with few ..

Read more

good day, I am using Tucker-Eric/EloquentFilter Laravel. I want to filter it by relationship using Models I want to automate it, instead of using the following: public function users($users) { // dd($users); return $this->r(‘users’, $users); } public function user($user) { // dd($user); return $this->r(‘user’, $user); } public function owner($owner) { // dd($owner); return $this->r(‘owner’, $owner); ..

Read more