Exemplo n.º 1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     $category = new Category();
     $listCategories = Category::lists('name', 'id')->prepend('Please Select Category');
     return view('category.create', compact('category', 'listCategories'));
 }
Exemplo n.º 2
0
 public function edit_subcategory($id, Request $request)
 {
     if (Subcategory::find($id)) {
         if ($request->all()) {
             $rules = array('subname' => 'required', 'category' => 'required', 'slug' => 'required');
             $validator = Validator::make($request->all(), $rules);
             if (!$validator->fails()) {
                 $category = Subcategory::find($id);
                 $category->subname = $request->input('subname');
                 $category->category_id = $request->input('category');
                 $category->slug = $request->input('slug');
                 $category->properties = $request->input('properties');
                 if ($category->save()) {
                     return redirect('master/subcategory/list');
                 }
             } else {
                 return redirect('master/subcategory/edit/' . $id)->with('error', 'Terdapat form kosong');
             }
         } else {
             $this->data['css_assets'] = Assets::load('css', ['admin_bootstrap', 'admin_css', 'font-awesome', 'skins']);
             $this->data['js_assets'] = Assets::load('js', ['jquery', 'admin_js', 'admin_bootstrap-js', 'slimscroll', 'fastclick']);
             $this->data['title'] = 'Subcategory | Edit';
             $this->data['category'] = Subcategory::find($id);
             $this->data['category_list'] = [' - Select - '] + Category::lists('name', 'id')->all();
             return view('admin_layout')->with('data', $this->data)->nest('content', 'subcategory/form', array('data' => $this->data));
         }
     } else {
         return redirect('master/subcategory/list');
     }
 }