Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel filter

<?php

namespace AppHttpControllers;

use AppUser;
use IlluminateHttpRequest;

class UserController extends Controller
{
    public function index(Request $request)
    {
        $users = User::where('is_active', true);

        if ($request->has('age_more_than')) {
            $users->where('age', '>', $request->age_more_than);
        }

        if ($request->has('gender')) {
            $users->where('gender', $request->gender);
        }

        if ($request->has('created_at')) {
            $users->where('created_at','>=', $request->created_at);
        }

        return $users->get();
    }
}
Comment

laravel filter array

   $nbr_heures = array_filter($request->all(), function ($key) {
            return strpos($key, 'nbr_heure_') === 0;
        }, ARRAY_FILTER_USE_KEY);
Comment

PREVIOUS NEXT
Code Example
Php :: phpmailer doesnt work on infinityfree 
Php :: laravel make model controller and migration one time 
Php :: text to sha256 converter in laravel 
Php :: how to use get php with index php with url 
Php :: laravel repository update multiple row 
Php :: canany else 
Php :: php is_assoc 
Php :: Undefined property: stdClass::$ 
Php :: drupal show php errors 
Php :: pagination always show 5 pages 
Php :: how to re assign value of associative array after assign in php 
Php :: Token capabilities in vault 
Php :: livewire check no errors 
Php :: Laravel get all parent categories for each category 
Php :: php echo example 
Php :: @yield laravel 
Php :: php strftime year 2 digits 
Php :: create a button add in laravel 
Php :: clear log file laravel 
Php :: url rewrite htaccess php 
Php :: PHP substr — Return part of a string 
Php :: wordpress if page 
Php :: send data with window.location.href 
Php :: what are the different types of PHP variables? 
Php :: php get last 3 elements of array 
Php :: unravel_index numpy 
Php :: if certain condition is met exit if block php 
Php :: mail function php not working 
Php :: php constants 
Php :: controller class does not exist laravel 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =