/** * Show the form for creating a new resource. * * @return Response */ public function create() { $visitortype = new VisitorType(); $visitortype->name = Input::get('name'); $visitortype->save(); return Response::json(array('success' => 'Visitor type has been added!')); }
public function handleCreateVisitortype() { // create the validation rules ------------------------ $rules = array('name' => 'required'); // do the validation ---------------------------------- // validate against the inputs from our form $validator = Validator::make(Input::all(), $rules); // check if the validator failed ----------------------- 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::action('CommonController@createVisitortype')->withErrors($validator)->withInput(); } else { $visitortype = new VisitorType(); $visitortype->name = Input::get('name'); $visitortype->save(); return Redirect::action('CommonController@visitortypes'); } }