PHP code example of ndp / customcollect

1. Go to this page and download the library: Download ndp/customcollect library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ndp / customcollect example snippets

sh
class Calendar {
    public $owner_name;
    /* @return collection */
    public function getEventsPerRange($startDate, $endDate){
        //TODO: implement method.
    }
}

class EventRepo extends Calendar {
    /* @var Collection $events */
    protected $events;
    public function __constructor(array $events){
        $this->events = collect($events);
    }
    public function selectEventsPerDateRange($startDate, $endDate){
        $this->events = $this->getEventsPerRange($startDate, $endDate);
        return $this;
    }
    public function get()
    {
        return $this->events;
    }
}

class Event {
    public $id,$owner_first_name,$owner_last_name,$address,organizer,$summary;
    //NOTE: somehow these properties get updated.

    public function getOrganizer(){
        return $this->organizer;
    }
    public function setOrganizer(Organizer $organizer){
        return $this->organizer =$organizer;
    }
}
class EventOrganizer {
    public $displayName,$email,$id;
}
sh
$repo = new EventRepo($events);
$events = $repo->selectEventsPerDateRange($startDate, $endDate)->get();
$eventsJson = collect();
foreach($events as $event){
    $event = new \sdClass();
    $event->{"organizer_name"} = $event->organizer->displayName;
    $event->{"contact_email} = $event->organizer->email;
    $eventJson->push($event);
}
return $eventsJson->toJson();
sh
composer dump-autoload