Example #1
0
 /**
  * Creates a new Todo model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Todo();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         $model->done = 0;
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(TodoRequest $request)
 {
     $todo = new Todo($request->all());
     $todo->save();
     return redirect()->route('admin.todos.index')->with('message', 'Se ha creado ' . $todo->name . ' de forma correcta.');
 }