app/Http/Controllers/CategoryController.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)
    {
        $category = Category::orderBy('name')
            ->when($request->has('q') && $request->q != "", function ($query) use ($request) {
                $query->where('name', 'LIKE', '%'. $request->q .'%');
            })
            ->paginate($request->rows ?? $this->paginate)
            ->appends($request->only('rows', 'q'));
        return view('category.index', compact('category'));
    }
public function index ( Request $ request ) { $ category = Category :: orderBy ( 'name' ) -> when ( $ request -> has ( 'q' ) && $ request -> q != " " , function ( $ query ) use ( $ request ) { $ query -> where ( 'name' , 'LIKE' , '%' . $ request -> q . '%' ) ; } ) -> paginate ( $ request -> rows ?? $ this -> paginate ) -> appends ( $ request -> only ( 'rows' , 'q' ) ) ; return view ( 'category.index' , compact ( 'category' ) ) ; }
Display a listing of the resource.
Display a listing of the resource .