Skip to content

Commit

Permalink
Laravel 5 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
maddhatter committed Feb 13, 2015
1 parent dc17fb9 commit afe16a3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"require": {
"php": ">=5.4.0",
"illuminate/support": "4.2.*"
"illuminate/support": "~5.0"
},
"autoload": {
"psr-0": {
Expand Down
27 changes: 15 additions & 12 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Laravel 4.2 Full Calendar Helper
# Laravel 5 Full Calendar Helper

***For Laravel 4.2: use the [laravel-4 branch](https://github.com/maddhatter/laravel-fullcalendar/tree/laravel-4)***

This is a simple helper package to make generating [http://fullcalendar.io](http://fullcalendar.io) in Laravel apps easier.

Expand All @@ -11,7 +13,7 @@ Or add the following to your composer.json's require section and `composer updat

```json
"require": {
"maddhatter/laravel-fullcalendar": "dev-master"
"maddhatter/laravel-fullcalendar": "~1.0"
}
```

Expand Down Expand Up @@ -39,7 +41,7 @@ The simpliest way to create an event is to pass the event information to `Calend


```php
$event = Calendar::event(
$event = \Calendar::event(
"Valentine's Day", //event title
true, //full day event?
'2015-02-14', //start time, must be a DateTime object or valid DateTime format (http://bit.ly/1z7QWbg)
Expand Down Expand Up @@ -106,30 +108,31 @@ To create a calendar, in your route or controller, create your event(s), then pa
```php
$events = [];

$events[] = Calendar::event(
$events[] = \Calendar::event(
'Event One', //event title
false, //full day event?
'2015-02-11T0800', //start time (you can also use Carbon instead of DateTime)
'2015-02-12T0800' //end time (you can also use Carbon instead of DateTime)
);

$events[] = Calendar::event(
$events[] = \Calendar::event(
"Valentine's Day", //event title
true, //full day event?
new DateTime('2015-02-14'), //start time (you can also use Carbon instead of DateTime)
new DateTime('2015-02-14') //end time (you can also use Carbon instead of DateTime)
new \DateTime('2015-02-14'), //start time (you can also use Carbon instead of DateTime)
new \DateTime('2015-02-14') //end time (you can also use Carbon instead of DateTime)
);

$eloquentEvent = EventModel::first(); //EventModel implements MaddHatter\LaravelFullcalendar\Event

$calendar = Calendar::addEvents($events) //add an array with addEvents
$calendar = \Calendar::addEvents($events) //add an array with addEvents
->addEvent($eloquentEvent, [ //set custom color fo this event
'color' => '#800',
]);

return View::make('hello', compact('calendar'));
return view('hello', compact('calendar'));
```


#### Sample View

Then to display, add the following code to your View:
Expand All @@ -149,12 +152,12 @@ Then to display, add the following code to your View:
</style>
</head>
<body>
{{ $calendar->calendar() }}
{{ $calendar->script() }}
{!! $calendar->calendar() !!}
{!! $calendar->script() !!}
</body>
</html>

```
**Note:** The output from `calendar()` and `script()` must be non-escaped, so use `{!!` and `!!}` (or whatever you've configured your Blade compiler's raw tag directives as).

The `script()` can be placed anywhere after `calendar()`, and must be after fullcalendar was included.

Expand Down
11 changes: 2 additions & 9 deletions src/MaddHatter/LaravelFullcalendar/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
class ServiceProvider extends BaseServiceProvider
{

/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;

/**
* Register the service provider.
*
Expand All @@ -26,7 +19,7 @@ public function register()

public function boot()
{
$this->package('madd-hatter/fullcalendar');
$this->loadViewsFrom(__DIR__ . '/../../views/', 'fullcalendar');
}

/**
Expand All @@ -36,7 +29,7 @@ public function boot()
*/
public function provides()
{
return array();
return ['laravel-fullcalendar'];
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/views/script.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
right: 'month,agendaWeek,agendaDay'
},
eventLimit: true,
events: {{ $events }}
events: {!! $events !!}
});
</script>

0 comments on commit afe16a3

Please sign in to comment.