コード例 #1
0
ファイル: OdotItemController.php プロジェクト: roypenrod/odot
 /**
  * Store a newly created list item in the database.
  *
  * @param  int  $listId
  *
  * @return Response
  */
 public function store($listId)
 {
     $list = OdotList::findOrFail($listId);
     // define the validation rules
     $validationRules = array('content' => array('required'));
     // validates the input
     $validator = Validator::make(Input::all(), $validationRules);
     // checks to see if the input fails validation
     if ($validator->fails()) {
         // if it's not valid, send them back
         // to the create list item form
         return Redirect::route('list.item.create', $listId)->withErrors($validator)->withInput();
     }
     $item = new OdotListItem();
     $item->content = Input::get('content');
     // save it
     $list->listItems()->save($item);
     return Redirect::route('list.show', $list->id)->with('message', 'Your item was added.');
 }
コード例 #2
0
ファイル: OdotListController.php プロジェクト: roypenrod/odot
 /**
  * Remove the list from the database.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $list = OdotList::findOrFail($id)->delete();
     return Redirect::route('list.index')->with('message', 'Your list was deleted.');
 }