app/Http/Controllers/ProductController.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)
    {
        $data = Product::latest()->paginate(20);
        if($request->has('search')){
            $data = Product::where('name','like',"%{$request->get('search')}%")->orWhere('sku','like',"%{$request->get('search')}%")->paginate(10);
        }
        return view('admin.product.index', [
            'data' => $data
        ]);
    }
public function index ( Request $ request ) { $ data = Product :: latest ( ) -> paginate ( 20 ) ; if ( $ request -> has ( 'search' ) ) { $ data = Product :: where ( 'name' , 'like' , " % { $ request -> get ( 'search' ) } % " ) -> orWhere ( 'sku' , 'like' , " % { $ request -> get ( 'search' ) } % " ) -> paginate ( 10 ) ; } return view ( 'admin.product.index' , [ 'data' => $ data ] ) ; }
Display a listing of the resource.
Display a listing of the resource .
//$data = Product::all();