示例#1
0
 public function deactivate($id)
 {
     $type = Type::find($id);
     $type->status = 0;
     $type->save();
     return redirect('home/types');
 }
示例#2
0
 public function update(Request $request, $id)
 {
     $this->validate($request, ['description' => 'required']);
     $type = Type::find($id);
     $type->fill($request->all());
     $type->save();
     return Redirect::to('types');
 }
 public function index()
 {
     $ingredients = Ingredient::all();
     foreach ($ingredients as $key => $item) {
         $ingredients[$key]['type'] = \App\Type::find($item->type_id);
     }
     return view('ingredient.index', array('ingredients' => $ingredients));
 }
示例#4
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     switch ($this->method()) {
         case 'POST':
             return ['name' => 'required|max:255|unique:types,name'];
         case 'PATCH':
             $type = Type::find($this->types);
             return ['name' => 'required|max:255|unique:types,name,' . $type->id];
     }
 }
示例#5
0
 public function show($id)
 {
     if ($id == 0) {
         $ingredients = Ingredient::all();
         foreach ($ingredients as $key => $item) {
             $ingredients[$key]['type'] = \App\Type::find($item->type_id);
         }
         return response()->json(['ingredients' => $ingredients]);
     } else {
         $aux = \App\Type::all();
         $types = $this->getTypes($aux);
         $ingredient = Ingredient::find($id);
         return response()->json(['ingredient' => $ingredient, 'types' => $types]);
     }
 }
示例#6
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     //
     $data = Type::find($id);
     Session::flash('message', 'Type name "' . $data->name . '" was successfully deleted');
     $data->delete();
     return redirect('/type');
 }
 public function update($id, TypeFormRequest $request)
 {
     $type = Type::find($id);
     $type->update(['type_name' => $request->input('type_name')]);
     return redirect()->route('admin.typeManagement');
 }
 public function edit($id)
 {
     $type = Type::find($id);
     return view('pages.types.edit', compact('type'));
 }
示例#9
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     //
     $v = Validator::make(Request::all(), ['name' => 'required|max:50']);
     if ($v->fails()) {
         return redirect()->back()->withErrors($v->errors())->withInput();
     } else {
         $id = Request::get('id');
         $type = Type::find($id);
         $type->name = Request::get('name');
         $type->desc = Request::get('desc');
         $type->price = Request::get('price');
         $type->size = Request::get('size');
         $type->save();
         return redirect('types');
     }
 }