/** * Show the form for creating a new resource. * * @return Response */ public function create() { if (Auth::user()) { $types = \App\Type::orderBy('name', 'asc')->get(); return view('jobs.create', compact('types')); } return redirect('login'); }
/** query responsibility */ public function getPractice() { //this returns the collection $type = \App\Type::orderBy('id', 'DESC')->get(); //now $type is the collection, and we can work from within that, like so. $first = $type->first(); dump($type); dump($first); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $search = \Request::get('search'); $getCategory = \Request::get('category'); if (is_null($search) || is_null($getCategory) || $search == "" || $getCategory == "") { $types = Type::orderBy('id', 'DESC')->paginate(10); } else { $types = Type::where($getCategory, 'like', '%' . $search . '%')->orderBy($getCategory)->paginate(1000); } $category = array('' => 'kategori', 'name' => 'Nama'); return view('type.index', compact('types', 'category')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $types = Type::orderBy('name', 'asc')->get(); return view('types.index', compact('types')); }