コード例 #1
0
 public function add()
 {
     // Check Author authentication Session
     if (!Auth::check('default')) {
         return $this->redirect('Authors::login');
     }
     // Retrieve current Author ID
     $author_id = Auth::check('default')->data['id'];
     $book = Books::create();
     if ($book && $this->request->data && $book->save($this->request->data)) {
         Session::write('message', 'Book has been created');
         $this->redirect(array('Authors::dashboard'));
     } else {
         Session::write('message', 'Book can not been created');
     }
     return compact('author_id', 'book');
 }