Example #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Colors();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Colors'])) {
         $model->attributes = $_POST['Colors'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->color_id));
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make(Input::all(), Colors::$rules);
     if ($validator->passes()) {
         $color = new Colors();
         $color->name = Input::get('name');
         $color->code = Input::get('code');
         $color->save();
         return Redirect::route('colors.index')->with('success', 'Unit created successfully');
     } else {
         return Redirect::route('colors.create')->withErrors($validator)->withInput(Input::all());
     }
 }