app/Http/Controllers/Admin/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)
    {
        $products = $this->product->with(['category.sizes', 'images'])->latest();
        if(!empty($request->search)) {
            $products = $products->where('name', 'like', "%{$request->search}%");
        }
        $products = $products->paginate(8);
        $products->appends(request()->input())->links();
        $categories = $this->category->groupBy('name')->orderBy('name')->get(['name']);
        return view('admin.web.product.index', compact('products', 'categories'));
    }
public function index ( Request $ request ) { $ products = $ this -> product -> with ( [ 'category.sizes' , 'images' ] ) -> latest ( ) ; if ( ! empty ( $ request -> search ) ) { $ products = $ products -> where ( 'name' , 'like' , " % { $ request -> search } % " ) ; } $ products = $ products -> paginate ( 8 ) ; $ products -> appends ( request ( ) -> input ( ) ) -> links ( ) ; $ categories = $ this -> category -> groupBy ( 'name' ) -> orderBy ( 'name' ) -> get ( [ 'name' ] ) ; return view ( 'admin.web.product.index' , compact ( 'products' , 'categories' ) ) ; }
Display a listing of the resource.
Display a listing of the resource .