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 :: variables in php 
Php :: laravel public static variable 
Php :: how to set logo in wordpress 
Php :: sync laravel 
Php :: wp-config.php 
Php :: what is cors in laravel 
Php :: laravel migration change column order 
Php :: laravel seeder with relationships 
Php :: js php number format space 
Php :: match uuid patter laravel regex 
Php :: how to fetch all user data form user in wp 
Php :: macrotime phph 
Php :: vindecoder.eu php 
Php :: how to check ia folder if no have files in php 
Php :: php return associative array 
Php :: php encrypt password 
Php :: Skip model mutator 
Php :: doble quotes in csv export php 
Php :: laravel query relationship nested 
Php :: Uncaught Error: Call to undefined function add_submenu_page() 
Php :: Find category name & link 
Php :: Laravel save without an event 
Php :: wc php get shipping methods 
Php :: woocommerce_product_is_on_sale filter 
Php :: phpmailer 
Php :: $faker-paragraph 
Php :: mssql php 
Php :: hot to use functions in heredoc 
Php :: how to enable auto refresh on save laravel 
Php :: laravel request protected prop 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =