public function candidate() { $author = $this->route('authors'); if (!$author) { throw new Exception('Group can be created only if author specified'); } $group = parent::candidate(); $group->author()->associate($author); return $group; }
public function candidate() { $group = $this->route('groups'); if (!$group) { throw new Exception('Page can be created only if group specified'); } $page = parent::candidate(); $page->author()->associate($group->author); $page->group()->associate($group); return $page; }
/** * Store a newly created entity entry in storage. * * @param EntityRequest $request * @return Response */ public function _store(EntityRequest $request) { $entity = $request->candidate(); if ($entity->save()) { return $this->innerRedirect('show', $entity)->withMessage('Saved'); } throw new Exception('Failed to save'); }