public function grow() { foreach ($this->events as $event) { $e = new GroupEvent(); $e->name = $event['name']; $e->place = $event['place']; $e->event_date = $event['event_date']; $e->description = $event['description']; $e->save(); } }
public function post_events_new() { $input = Input::all(); try { $validator = new Services\Dashboard\Events\Validator($input); $validator->publish(); } catch (ValidateException $errors) { return Redirect::to(URL::to_route('dashboard.events.new'))->with_input()->with_errors($errors->get()); } $errors = new Laravel\Messages(); if (!empty($input['event_name'])) { $input['event_name'] = filter_var($input['event_name'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES); } if (!empty($input['event_place'])) { $input['event_place'] = filter_var($input['event_place'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES); } if (!empty($input['event_description'])) { $input['event_description'] = filter_var($input['event_description'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES); } if (!empty($input['event_date'])) { $pieces = explode("/", $input['event_date']); $lang = Config::get('application.language', 'en'); if ($lang == 'en') { $input['event_date'] = date('Y-m-d', mktime(0, 0, 0, $pieces[0], $pieces[1], $pieces[2])); } else { $input['event_date'] = date('Y-m-d', mktime(0, 0, 0, $pieces[1], $pieces[0], $pieces[2])); } } $event = new GroupEvent(); $event->name = $input['event_name']; $event->place = $input['event_place']; $event->event_date = $input['event_date']; $event->description = $input['event_description']; if ($event->save()) { return Redirect::to(URL::to_route('dashboard.events'))->with('status_success', __('application.event_added')); } else { $errors->add('errors', __('application.generic_error')); return Redirect::to(URL::to_route('dashboard.events.new'))->with_input()->with_errors($errors); } }