Search
 
SCRIPT & CODE EXAMPLE
 

PHP

multiple search filter in laravel

public function index(Request $request)
    {
        $search =  $request->input('q');
        if($search!=""){
            $Members = Member::where(function ($query) use ($search){
                $query->where('name', 'like', '%'.$search.'%')
                    ->orWhere('email', 'like', '%'.$search.'%');
            })
            ->paginate(2);
            $Members->appends(['q' => $search]);
        }
        else{
            $Members = Member::paginate(2);
        }
        return View('pages.search')->with('data',$Members);
        //
    }
Comment

multiple field query filtering in Laravel

public function show(Request $request)
{
    $annonces = Annonce::when($request->term, function ($query, $term) {
        return $query->where('title', 'like', "%{$term}%");
    })->when($request->categorie, function ($query, $categorie) {
        return $query->where('categorie', 'like', "%{$categorie}%");
    })->when($request->price && in_array($request->price, ['more-expensive', 'less-expensive']), function ($query) use ($request) {
        return $query->orderBy('price', $request->price == 'less-expensive' ? 'asc' : 'desc');
    }, function ($query) {
        return $query->orderByDesc('id');
    })->paginate(15);

    return view('welcome', compact('annonces'));
}
Comment

PREVIOUS NEXT
Code Example
Php :: left join laravel 
Php :: laravel 6 get user id 
Php :: Yii::app()-request-get yii1 
Php :: socialite laravel 7 
Php :: laravel date format 
Php :: php array_filter 
Php :: laravel store method 
Php :: laravel get single column value 
Php :: php check valid time format 
Php :: laravel fixed character limit 
Php :: symfony header token authorization 
Php :: string to array in php 
Php :: PHP validation/regex for URL 
Php :: How to JSON encode a PHP array 
Php :: collapse open by default 
Php :: how to get last id in database codeigniter 4 
Php :: laravel created_at changing 
Php :: subtract string php 
Php :: get where different laravel 
Php :: How to Show the Logged in Username in the WordPress 
Php :: php curl Content-Length 
Php :: users not having any role laravel spatie 
Php :: carbon get day name from date 
Php :: get post index wordpress 
Php :: php string to uppercase 
Php :: php laravel config 
Php :: php 7 starts with 
Php :: how to use xampp for php and mysql 
Php :: running laravel queues in shared hosting 
Php :: uuidv4 php 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =