Beispiel #1
0
 private function placeFrom($id)
 {
     if ($cityFr = Place::where('id', '=', $id)->first()) {
         return $cityFr->full_name;
     } else {
         return null;
     }
 }
 /**
  * Edit or create a clubevent with its entered information.
  * If $id is null create a new clubEvent, otherwise the clubEvent specified by $id will be edit. 
  *
  * @param int $id
  * @return ClubEvent clubEvent
  */
 private function editClubEvent($id)
 {
     $event = new ClubEvent();
     if (!is_null($id)) {
         $event = ClubEvent::findOrFail($id);
     }
     // format: strings; no validation needed
     $event->evnt_title = Input::get('title');
     $event->evnt_subtitle = Input::get('subtitle');
     $event->evnt_public_info = Input::get('publicInfo');
     $event->evnt_private_details = Input::get('privateDetails');
     $event->evnt_type = Input::get('evnt_type');
     // create new place
     if (!Place::where('plc_title', '=', Input::get('place'))->first()) {
         $place = new Place();
         $place->plc_title = Input::get('place');
         $place->save();
         $event->plc_id = $place->id;
     } else {
         $event->plc_id = Place::where('plc_title', '=', Input::get('place'))->first()->id;
     }
     // format: date; validate on filled value
     if (!empty(Input::get('beginDate'))) {
         $newBeginDate = new DateTime(Input::get('beginDate'), new DateTimeZone(Config::get('app.timezone')));
         $event->evnt_date_start = $newBeginDate->format('Y-m-d');
     } else {
         $event->evnt_date_start = date('Y-m-d', mktime(0, 0, 0, 0, 0, 0));
     }
     if (!empty(Input::get('endDate'))) {
         $newEndDate = new DateTime(Input::get('endDate'), new DateTimeZone(Config::get('app.timezone')));
         $event->evnt_date_end = $newEndDate->format('Y-m-d');
     } else {
         $event->evnt_date_end = date('Y-m-d', mktime(0, 0, 0, 0, 0, 0));
     }
     // format: time; validate on filled value
     if (!empty(Input::get('beginTime'))) {
         $event->evnt_time_start = Input::get('beginTime');
     } else {
         $event->evnt_time_start = mktime(0, 0, 0);
     }
     if (!empty(Input::get('endTime'))) {
         $event->evnt_time_end = Input::get('endTime');
     } else {
         $event->evnt_time_end = mktime(0, 0, 0);
     }
     // format: tinyInt; validate on filled value
     // reversed this: input=1 means "event is public", input=0 means "event is private"
     $event->evnt_is_private = Input::get('isPrivate') == '1' ? 0 : 1;
     return $event;
 }