src/Services/CalendarEventsService.php
protected function handleEventLocation(array $data, Models\CalendarEvent $calendarEvent)
    {
        if (array_key_exists('longitude', $data) && !empty($data['longitude'])) {
            $this->eventLocation->longitude = $data['longitude'];
        }

        if (array_key_exists('latitude', $data) && !empty($data['latitude'])) {
            $this->eventLocation->latitude = $data['latitude'];
        }

        if (array_key_exists('address', $data) && !empty($data['address'])) {
            $this->eventLocation->address = $data['address'];
        }

        if (
            (!empty($this->eventLocation->longitude) && !empty($this->eventLocation->latitude)) ||
            !empty($this->eventLocation->address)
        ) {
            $this->eventLocation->calendarEvent()
                                ->associate($calendarEvent)
            ;
            $this->eventLocation->save();

            return $this->eventLocation;
        }

        return null;
    }
protected function handleEventLocation(array $data, Models\CalendarEvent $calendarEvent)
    {
        if (array_key_exists('longitude', $data) && !empty($data['longitude'])) {
            $this->eventLocation->longitude = $data['longitude'];
        }

        if (array_key_exists('latitude', $data) && !empty($data['latitude'])) {
            $this->eventLocation->latitude = $data['latitude'];
        }

        if (array_key_exists('address', $data) && !empty($data['address'])) {
            $this->eventLocation->address = $data['address'];
        }

        if (
            (!empty($this->eventLocation->longitude) && !empty($this->eventLocation->latitude)) ||
            !empty($this->eventLocation->address)
        ) {
            $this->eventLocation->calendarEvent()
                                ->associate($calendarEvent)
            ;
            $this->eventLocation->save();

            return $this->eventLocation;
        }

        return null;
    }
protected function handleEventLocation ( array $ data , Models \ CalendarEvent $ calendarEvent ) { if ( array_key_exists ( 'longitude' , $ data ) && ! empty ( $ data [ 'longitude' ] ) ) { $ this -> eventLocation -> longitude = $ data [ 'longitude' ] ; } if ( array_key_exists ( 'latitude' , $ data ) && ! empty ( $ data [ 'latitude' ] ) ) { $ this -> eventLocation -> latitude = $ data [ 'latitude' ] ; } if ( array_key_exists ( 'address' , $ data ) && ! empty ( $ data [ 'address' ] ) ) { $ this -> eventLocation -> address = $ data [ 'address' ] ; } if ( ( ! empty ( $ this -> eventLocation -> longitude ) && ! empty ( $ this -> eventLocation -> latitude ) ) || ! empty ( $ this -> eventLocation -> address ) ) { $ this -> eventLocation -> calendarEvent ( ) -> associate ( $ calendarEvent ) ; $ this -> eventLocation -> save ( ) ; return $ this -> eventLocation ; } return null ; }
Handles EventLocation save/update

@param array $data

@param \Todstoychev\CalendarEvents\Models\CalendarEvent $calendarEvent

@return null|\Todstoychev\CalendarEvents\Models\EventLocation
Handles EventLocation save / update