public function postCreate() { // validate against the inputs from our form $validator = Validator::make(Input::all(), $this->rules); if ($validator->fails()) { // get the error messages from the validator $messages = $validator->messages(); // redirect our user back to the form with the errors from the validator return Redirect::back()->withErrors($messages); } else { $year = substr(Input::get('year'), 0, 5); if (Input::get('status') == 'active' && count(Competency::getActive()) > 0) { //check active return Redirect::back()->with('message', 'data gagal ditambah'); } else { $schedule = new Competency(); $schedule->year = (int) $year; $schedule->date_start = Input::get('date_start'); $schedule->date_end = Input::get('date_end'); $schedule->status = Input::get('status'); $schedule->save(); return Redirect::to('admin/competency/schedule/')->with('message', 'data berhasil ditambah'); } } }