app/Http/Controllers/Dashboard/ClientController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index(Request $request)
    {
        $clients = Client::when($request->search, function($q) use ($request){
            return $q->where('name' , 'like' ,'%' . $request->search . '%')
            ->orwhere('phone' , 'like' ,'%' . $request->search .'%')
            ->orwhere('address' , 'like' ,'%' . $request->search .'%');
        })->latest()->paginate(5);
        return view('dashboard.clients.index' ,compact('clients'));
    }
public function index ( Request $ request ) { $ clients = Client :: when ( $ request -> search , function ( $ q ) use ( $ request ) { return $ q -> where ( 'name' , 'like' , '%' . $ request -> search . '%' ) -> orwhere ( 'phone' , 'like' , '%' . $ request -> search . '%' ) -> orwhere ( 'address' , 'like' , '%' . $ request -> search . '%' ) ; } ) -> latest ( ) -> paginate ( 5 ) ; return view ( 'dashboard.clients.index' , compact ( 'clients' ) ) ; }
Display a listing of the resource.
Display a listing of the resource .