/**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $request = request();
     $name = $request->has('name') ? $request->get('name') : '';
     $categories = ItemCategory::where(function ($query) use($name) {
         if (!empty($name)) {
             $query->where('name', 'LIKE', "%{$name}%");
         }
     })->paginate(env('LIMIT', 15));
     return view('store.categories.index', compact('categories', 'name'));
 }
예제 #2
0
 public function __construct()
 {
     $this->categories = ['' => 'Select'] + ItemCategory::where('is_active', 1)->lists('name', 'id')->all();
 }