PHP code example of schedulemycoach / laravel7-fullcalendar
1. Go to this page and download the library: Download schedulemycoach/laravel7-fullcalendar 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/ */
schedulemycoach / laravel7-fullcalendar example snippets
'providers' => [
...
schedulemycoach\Fullcalendar\FullcalendarServiceProvider::class,
],
'aliases' => [
...
'Fullcalendar' => schedulemycoach\Fullcalendar\Facades\Fullcalendar::class,
],
public function index()
{
// Generate a new fullcalendar instance
$calendar = new \schedulemycoach\Fullcalendar\Fullcalendar();
// You can manually add the objects as an array
$events = $this->getEvents();
$calendar->setEvents($events);
// Or you can add a route and return the events using an ajax requests that returns the events as json
$calendar->setEvents(route('fullcalendar-ajax-events'));
// Set options
$calendar->setOptions([
'locale' => 'en',
'weekNumbers' => true,
'selectable' => true,
'themeSystem' =>'bootstrap',
/* Scripts need for this are not quest
* @return string
*/
public function ajaxEvents(Request $request)
{
// start and end dates will be sent automatically by fullcalendar, they can be obtained using:
// $request->get('start') & $request->get('end')
$events = $this->getEvents();
return json_encode($events);
}
/**
* @return array
*/
private function getEvents()
{
$events = [];
$events[] = new \schedulemycoach\Fullcalendar\Event([
'id' => 0,
'title' => 'Rest',
'allDay' => true,
'start' => Carbon::create(2016, 11, 20),
'end' => Carbon::create(2016, 11, 20),
]);
$events[] = new \schedulemycoach\Fullcalendar\Event([
'id' => 1,
'title' => 'Appointment #' . rand(1, 999),
'start' => Carbon::create(2016, 11, 15, 13),
'end' => Carbon::create(2016, 11, 15, 13)->addHour(2),
]);
$events[] = new \schedulemycoach\Fullcalendar\Event([
'id' => 2,
'title' => 'Appointment #' . rand(1, 999),
'editable' => true,
'startEditable' => true,
'durationEditable' => true,
'start' => Carbon::create(2016, 11, 16, 10),
'end' => Carbon::create(2016, 11, 16, 13),
]);
$events[] = new \schedulemycoach\Fullcalendar\Event([
'id' => 3,
'title' => 'Appointment #' . rand(1, 999),
'editable' => true,
'startEditable' => true,
'durationEditable' => true,
'start' => Carbon::create(2016, 11, 14, 9),
'end' => Carbon::create(2016, 11, 14, 10),
'backgroundColor' => 'black',
'borderColor' => 'red',
'textColor' => 'green',
]);
return $events;
}
{!! $calendar->generate() !!}
$ php composer.phar
php artisan vendor:publish --tag=config
php artisan vendor:publish --tag=fullcalendar