public function createFeedback() { $validator = Validator::make(Input::all(), $this->rules); if ($validator->passes()) { $testimonial = new Testimonial(); $count = Testimonial::orderby('ID_Feedback', 'DESC')->first(); $tampID = $count->ID_Feedback; $checkYear = substr(strval($tampID), 3, -5); $incrementID = substr($tampID, 3) + 1; $join = "FED" . $incrementID; date_default_timezone_set('Asia/Jakarta'); $date = date('Y-m-d h:i:s', time()); if ($checkYear == strval(date("y"))) { $testimonial->ID_Feedback = $join; $testimonial->Name = Input::get('feed-fullname'); $testimonial->Email = Input::get('feed-email'); $testimonial->Subject = Input::get('feed-subject'); $testimonial->Message = Input::get('feed-message'); $testimonial->Date = $date; $testimonial->Status = "Pending"; $testimonial->save(); return Redirect::to('/testimonial')->with('message', 'Success'); } else { $testimonial = new Testimonial(); date_default_timezone_set('Asia/Jakarta'); $date = date('Y-m-d h:i:s', time()); $testimonial->ID_Feedback = "FED" . date('y') . "00001"; $testimonial->Name = Input::get('feed-fullname'); $testimonial->Email = Input::get('feed-email'); $testimonial->Subject = Input::get('feed-subject'); $testimonial->Message = Input::get('feed-message'); $testimonial->Date = $date; $testimonial->Status = "Pending"; $testimonial->save(); return Redirect::to('/testimonial')->with('message', 'Success'); } } else { return Redirect::to('/testimonial')->withErrors($validator, 'feedback')->withInput()->with('active', 'active'); } }