maddhatter / laravel-fullcalendar

Laravel FullCalendar.io Helper
627 stars 267 forks source link

Database events #30

Open kirubidavid opened 8 years ago

kirubidavid commented 8 years ago

Hi, Is it possible to get multiple events from a database?

I have tried:

$eloquentEvent = EventModel::where('status','=','Approved')->get();

$calendar = Calendar::addEvents($events)->addEvent($eloquentEvent, ['color' => '#800', ]);

I Get an error

Argument 1 passed to MaddHatter\LaravelFullcalendar\Calendar::addEvent() must implement interface MaddHatter\LaravelFullcalendar\Event, instance of Illuminate\Database\Eloquent\Collection given, called in D:\######\app\controllers\CrystalController.php on line 34 and defined

I would also like to assign multiple colors for different events.

maddhatter commented 8 years ago

Are you using Laravel 4 or 5+?

kirubidavid commented 8 years ago

Laravel 4

maddhatter commented 8 years ago

You should be able to pass an Eloquent collection to the addEvents() method (note the plural).

I made changes to allow adding any FullCalendar property (including color) to events, but I don't remember if that change was backported to the Laravel 4 branch... let me look into that.

lablushah commented 8 years ago

I can pass Eloquent collection to the addEvents() method, but how do I pass uniqe url for each event? I can only pass a single url for the whole collection.

marorij commented 8 years ago

as I can print the calendar with all months?