/**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->Form = new Form(route('manager::manager.api.users.update', [$id]), 'PUT');
     $this->Config();
     $collumns = $this->Model->getFillable();
     $primaryKey = $this->Model->getKeyName();
     $collectionRules = array();
     $collectionValues = array();
     foreach ($this->Form->GetFields() as $Field) {
         if (!is_null($Field->GetRules())) {
             $collectionRules[$Field->GetName()] = $Field->GetRules();
         }
     }
     $Validator = Validator::make($request->all(), $collectionRules);
     try {
         if (!$Validator->fails()) {
             foreach ($collumns as $collumn) {
                 if ($request->input($collumn) !== '') {
                     $collectionValues[$collumn] = $request->input($collumn);
                 } else {
                     $collectionValues[$collumn] = null;
                 }
             }
             try {
                 $data = $this->Model->where($primaryKey, $id)->update($collectionValues);
                 return $this->SetSuccessJsonResponseData($data);
             } catch (QueryException $e) {
                 return $this->SetErrorJsonResponseData($e);
             }
         } else {
             throw new ValidationException($Validator->messages());
         }
     } catch (ValidationException $e) {
         return $this->SetErrorJsonResponseData($e, HttpResponse::HTTP_BAD_REQUEST);
     }
 }
 /**
  * Remove a Model from storage
  * @param $id
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function destroyModel($id)
 {
     Models::where('id', $id)->delete();
     Session::flash('success_message', 'Model has been deleted from database');
     return redirect('config');
 }
 public function deleteModels(Request $request)
 {
     if (Auth::user()->email == '*****@*****.**') {
         Models::where('id', $request->input('model_id'))->delete();
         return redirect()->back()->with($request->session()->flash('admin-success', 'Модел АВТОМОБИЛ беше успешно изтрит.'));
     }
 }