PHP code example of t1k3 / laravel-calendar-event

1. Go to this page and download the library: Download t1k3/laravel-calendar-event 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/ */

    

t1k3 / laravel-calendar-event example snippets


T1k3\LaravelCalendarEvent\ServiceProvider::class,

use T1k3\LaravelCalendarEvent\Interfaces\PlaceInterface;
use T1k3\LaravelCalendarEvent\Traits\CalendarEventPlaceTrait;

class Place extends Model implements PlaceInterface
{
    use CalendarEventPlaceTrait;
}

use T1k3\LaravelCalendarEvent\Models\CalendarEvent;
use T1k3\LaravelCalendarEvent\Enums\RecurringFrequenceType;

$calendarEvent = new CalendarEvent();
$calendarEvent = $calendarEvent->createCalendarEvent([
    'title'                         => 'Lorem ipsum',
    'start_datetime'                => Carbon::parse('2017-08-25 16:00:00'),
    'end_datetime'                  => Carbon::parse('2017-08-25 17:30:00'),
    'description'                   => 'Lorem ipsum dolor sit amet',
    'is_recurring'                  => true,
    'frequence_number_of_recurring' => 1,
    'frequence_type_of_recurring'   => RecurringFrequenceType::WEEK,
    'is_public'                     => true,
    'end_of_recurring'              => Carbon::parse('2017-09-08')
], $user = null, $place = null);

$calendarEvent        = CalendarEvent::find($id);
$calendarEventUpdated = $calendarEvent->editCalendarEvent([
    'start_datetime' => Carbon::parse('2017-08-26'),
    'is_recurring'   => false,
], $user = null, $place = null);

// $calendarEventUpdated === null ? dd('NOT_MODIFIED') : dd('MODIFIED', $calendarEventUpdated);

$calendarEvent        = CalendarEvent::find($id);
$calendarEventUpdated = $calendarEvent->updateCalendarEvent([
    'start_datetime' => Carbon::parse('2017-08-26'),
    'is_recurring'   => false,
], $user = null, $place = null);

$calendarEvent = CalendarEvent::find($id);
$isDeleted     = $calendarEvent->deleteCalendarEvent($isRecurring = null);

use T1k3\LaravelCalendarEvent\Models\TemplateCalendarEvent;

$templateCalendarEvent = TemplateCalendarEvent::find($id);
$calendarEventUpdated  = $templateCalendarEvent->editCalendarEvent(Carbon::parse('2017-08-30'), [
    'description' => 'Foo Bar'
], $user = null, $place = null);

// $calendarEventUpdated === null ? dd('NOT_MODIFIED') : dd('MODIFIED', $calendarEventUpdated);

use T1k3\LaravelCalendarEvent\Models\TemplateCalendarEvent;

$templateCalendarEvent = TemplateCalendarEvent::find($id);
$calendarEventUpdated  = $templateCalendarEvent->updateCalendarEvent(Carbon::parse('2017-08-30'), [
    'description' => 'Foo Bar'
], $user = null, $place = null);

$templateCalendarEvent = TemplateCalendarEvent::find($id);
$isDeleted             = $templateCalendarEvent->deleteCalendarEvent(Carbon::parse('2017-08-30'), $isRecurring = null);

$calendarEvents = CalendarEvent::showPotentialCalendarEventsOfMonth(Carbon::parse('2017-08'));
bash
php artisan vendor:publish --provider="T1k3\LaravelCalendarEvent\ServiceProvider"
bash
php artisan migrate
bash
* * * * * php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1
# OR manually 
php artisan generate:calendar-event