arkhas/laravel5calendar

A calendar with event managment package for laravel 5 using Carbon and Blade templating

Downloads

1585

Stars

14

Version

v1.0.7

Installation

Install the package through Composer :

composer require arkhas/laravel5calendar

Now all you have to do is add the service provider of the package and alias the package. To do this open your app/config/app.php file.

Add a new line to the service providers array:

Arkhas\Calendar\CalendarServiceProvider::class,

Add a new line to the aliases array:

'Calendar' => Arkhas\Calendar\Facades\Calendar::class,

Then insert this in the top of your file :

use Calendar;

Or use it directly :

$calendar = \Calendar::generate();

Now you're ready to start using the calendar package in your application.

Usage

You can use the generate method to generate a calendar, it will return the template of the calendar.

// Generate a calendar for the current month and year
$calendar = Calendar::generate();

// Generate a calendar for the specified year and month
$calendar = Calendar::generate(2012, 5);

// Add an array of events as the third parameter to add them to the calendar (YYYY/MM/DD), 
$events = array(
	'2016/5/3',
	'2016/5/5',
	'2016/5/11',
	'2016/5/16',
	'2016/5/28',
);

$calendar = Calendar::generate(2016, 5, $events);

// Add an array of data as the fourth parameter so you can use them in the view :

$data = array(
	'name' => 'Arkhas',
	'url'  =>  '/event/arkhas',
	'foo' => 'bar'
);

$calendar = Calendar::generate(2016, 5, $events, $data);

For using it in you view, simply use :

{!! $calendar !!}

Routing

By default, the routing format is /calendar/YYYY/MM , you can change the leading route using the url data parameter :

$data['url'] = '/foo/bar/';

Template

If you want to use a custom template, run :

php artisan vendor:publish

The template is located in resources/views/vendor/calendar/calendar.blade.php

The css file is located in public/assets/arkhas/calendar/calendar.css

Navigate through the calendar

Add this to your template

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="/assets/arkhas/calendar/calendar.js"></script>

Navigate through the calendar with links using the calendarButton Class. The ajax script will replace the calendar class by an updated calendar.

For more information about how it work, you can navigate to /arkhas/demo and see the template in ressources/views/vendor/calendar/demo.blade.php

Arkhas

Author

Arkhas