Devise\Pages\PageManager::updatePage PHP Метод

updatePage() публичный Метод

Validates and updates a page with the given input
public updatePage ( integer $id, array $input ) : boolean
$id integer
$input array
Результат boolean
    public function updatePage($id, $input)
    {
        $input = array_only($input, static::$PageFields);
        $page = $this->Page->findOrFail($id);
        $this->validator = $this->Validator->make($input, $this->Page->updateRules, $this->Page->messages);
        if ($this->validator->passes()) {
            $page->update($input);
            $this->cacheDeviseRoutes();
            return $page;
        }
        $this->errors = $this->validator->errors()->all();
        $this->message = "There were validation errors.";
        return false;
    }

Usage Example

Пример #1
0
 /**
  * Request page be updated with given input
  *
  * @param  integer $id
  * @param  array   $input
  * @return Redirector
  */
 public function requestUpdatePage($id, $input)
 {
     $page = $this->PageManager->updatePage($id, $input);
     if ($page) {
         return $this->Redirect->route('dvs-pages')->with('warnings', $this->PageManager->warnings)->with('message', $this->PageManager->message);
     }
     return $this->Redirect->route('dvs-pages-edit', $id)->withInput()->withErrors($this->PageManager->errors)->with('message', $this->PageManager->message);
 }