App\Model\AlbumRepository::insert PHP Method

insert() public method

public insert ( $values ) : ActiveRow
return Nette\Database\Table\ActiveRow
    public function insert($values)
    {
        return $this->findAll()->insert($values);
    }

Usage Example

 public function albumFormSucceeded($button)
 {
     $values = $button->getForm()->getValues();
     $id = (int) $this->getParameter('id');
     if ($id) {
         $this->albums->findById($id)->update($values);
         $this->flashMessage('The album has been updated.');
     } else {
         $this->albums->insert($values);
         $this->flashMessage('The album has been added.');
     }
     $this->redirect('default');
 }