/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $val = $this->eventRepository->getCreateForm();
     if (!$val->isValid()) {
         return Redirect::back()->withInput()->withErrors($val->getErrors());
     }
     if (Input::get('date_start') > Input::get('date_end')) {
         return Redirect::back()->with('error', 'Date Start must be lesser than date end')->withInput();
     }
     if (!($event = $this->eventRepository->create($val->getInputData()))) {
         return Redirect::back()->with('errors', $this->eventRepository->errors())->withInput();
     }
     if (!($setting = $this->settingRepository->create(['settingable_type' => 'EventModel', 'settingable_id' => $event->id]))) {
         $this->eventRepository->delete($event);
         //@todo redirect
         return Redirect::back()->with('errors', 'could not create event');
     }
     // update the tags
     $tags = is_array(Input::get('tags')) ? array_filter(Input::get('tags')) : [];
     $this->tagRepository->attachTags($event, $tags);
     // Create a settings record for the inserted event
     // Settings Record needs to know Which type of Record and The Foreign Key it needs to Create
     // So pass these fields with Session (settableType,settableId)
     return Redirect::action('AdminSettingsController@edit', [$setting->id, 'store' => 'true']);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $val = $this->packageRepository->getCreateForm();
     if (!$val->isValid()) {
         return Redirect::back()->withInput()->withErrors($val->getErrors());
     }
     if (!($package = $this->packageRepository->create($val->getInputData()))) {
         return Redirect::back()->with('errors', $this->packageRepository->errors())->withInput();
     }
     if (!($setting = $this->settingRepository->create(['settingable_type' => 'Package', 'settingable_id' => $package->id]))) {
         $this->eventRepository->delete($package);
         //@todo redirect
         dd('could not create event');
     }
     // Create a settings record for the inserted event
     // Settings Record needs to know Which type of Record and The Foreign Key it needs to Create
     // So pass these fields with Session (settableType,settableId)
     return Redirect::action('AdminSettingsController@edit', $setting->id);
 }