maddhatter / laravel-fullcalendar Goto Github PK
View Code? Open in Web Editor NEWLaravel FullCalendar.io Helper
Laravel FullCalendar.io Helper
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.
Thanks @maddhatter for the updates to this - I ran it on 4.2 and its very clean. I'm moving over my project to Laravel 5 next month - any plans to update this for L5 or tips on how I might do that? Thanks again!
Awesome package - exactly what I was looking for in terms of integration of the fullcalendar library into Laravel. Are you putting together documentation for this? Packagist has the require bit but I'm not sure about other usage. Looking through all the classes now to get an idea but docs would be most helpful. ๐ for the package though!
i need change the language of te calendar to 'es'
by default, i pasted this in Calendar.php
and didn't work
protected $defaultOptions = [
'header' => [
'left' => 'prev,next today',
'center' => 'title',
'right' => 'month,agendaWeek,agendaDay',
],
'eventLimit' => true,
'lang' => 'es'
];
does this package work on laravel 5.1 or 5.2?
How do I call the calendar when I want to remove an event? I am using Ajax.
for example this code:
eventClick: function( event, jsEvent, view ) {
$.ajax({
url: 'calendar/remove_event.php',
data: 'id=' + event.id,
type: "POST",
success: function () {
$('#calendar').fullCalendar('removeEvents', calEvent._id);
}
});
},
Hey,
just did a fresh composer install of laravel-fullcalendar and followed instructions for installation.
Then i copied the sample code for the view and controller and I am getting the following error
Fatal error: Class 'App\Http\Controllers\EventModel' not found
I tried adding use at the top to ensure it was looking for the right class
use MaddHatter\LaravelFullcalendar\Calendar;
we also have a header.php that gets included and I placed the links to the fullcalendar files in there so they are included.
any thoughts on what I have done wrong ?
Thanks
How do i access the event's title for example?
Hi!
I'm a bit new to this and I just cant figure out how to edit the script file ({!! $calendar->script() !!}) you set in the view so i can use the custom options from fullcalendar.io ? I would appreciate the help.
After updating the package for Laravel 4.2 I have started to receive an error message with the following:
Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_ERROR) Symfony\Component\Debug\Exception\FatalErrorException thrown with message "Method Illuminate\View\View::__toString() must not throw an exception" Stacktrace: #1 Symfony\Component\Debug\Exception\FatalErrorException in editted/app/controllers/CalController.php:0 #0 Illuminate\Exception\Handler:handleShutdown in <#unknown>:0
Method Illuminate\View\View::__toString() must not throw an exception
I have a very basic implementation without changing the default options or using any callbacks.
I tried to add lang => 'bg' in setOptions but apperantly it didnt work. Is it featured?
Nice package!
How can we change event colors?
after getting everything ready got this error, any idea about that
Call to a member function format() on a non-object
'start' => $event->getStart()->format('c'),
So the question is if calendar is open by 2 users is it possible that calendar updates.
For example after external event drop, resize or drag.
I was trying with
$('#calendar-schedule').fullCalendar( 'refetchEvents' );
and
$('#calendar-schedule').fullCalendar( 'refetchEventSources', sources );
But no luck so far!
Does anyone have suggestion?
I found script and php that works, but no idea how to implement with this repo.
setCallbacks
eventDragStop: function (event, jsEvent, ui, view) {
if (isElemOverDiv()) {
var con = confirm('Are you sure to delete this event permanently?');
if(con == true) {
$.ajax({
url: 'process.php',
data: 'type=remove&eventid='+event.id,
type: 'POST',
dataType: 'json',
success: function(response){
console.log(response);
if(response.status == 'success'){
$('#calendar').fullCalendar('removeEvents');
getFreshEvents();
}
},
error: function(e){
alert('Error processing your request: '+e.responseText);
}
});
}
}
}
function getFreshEvents(){
$.ajax({
url: 'process.php',
type: 'POST', // Send post data
data: 'type=fetch',
async: false,
success: function(s){
freshevents = s;
}
});
$('#calendar').fullCalendar('addEventSource', JSON.parse(freshevents));
}
and
Controller store method
if($type == 'fetch')
{
$events = array();
$query = mysqli_query($con, "SELECT * FROM calendar");
while($fetch = mysqli_fetch_array($query,MYSQLI_ASSOC))
{
$e = array();
$e['id'] = $fetch['id'];
$e['title'] = $fetch['title'];
$e['start'] = $fetch['startdate'];
$e['end'] = $fetch['enddate'];
$allday = ($fetch['allDay'] == "true") ? true : false;
$e['allDay'] = $allday;
array_push($events, $e);
}
echo json_encode($events);
}
This should work, but how to impliment here?
... or to addEvent.
I`ve tried this
$calendar = \Calendar::addEvent([
'title' => $task->patient),
'allDay' => false,
'start' => $task->from_date,
'end' => $task->to_date,
'url' => route( 'dashboard.task.show', $task->id )
]);
but it doesn`t work. Am I missing something ?
as var cal = $('#calendar-{{ $id }}').fullCalendar({{ $options }});
because if i want to render event into the select function i received error "$(...).fullCalendar is not a function"
Can you add support for laravel 5.3?
This is my test code/controller
$calendar = \Calendar::addEvents($eloquentEvents) //add an array with addEvents
->setOptions([ //set fullcalendar options
'minTime' => '10:00',
'maxTime' => '22:00',
'editable' => false, // enable draggable events
'droppable' => true, // this allows things to be dropped onto the calendar
'resourceGroupField' =>'room',
'resourceLabelText' =>'Rooms',
'axisFormat' =>'HH(:mm)',
'header' => [
'left' => 'today prev,next',
'center' =>'title',
'right' =>'timelineDay,timelineThreeDays,agendaWeek,month'],
'views' => [
'timelineDay' => [
'timeFormat' => 'H:mm',
'type' => 'timeline',
'duration' => [ 'days' => 1 ]
],
],
'resources' => [
[ 'id' => '1',
'room' => '1. Flor',
'title' => 'Table No.: 1'
],
[ 'id' => '2',
'room' => '1. Flor',
'title' => 'Table No.: 2'
],
[ 'id' => '3',
'building' => '2. Flor',
'title' => 'Table No.: 1'
],
[ 'id' => '4',
'room' => '2. Flor',
'title' => 'Table No.: 2'
],
[ 'id' => '5',
'room' => '2. Flor',
'title' => 'Table No.: 3'
],
],
])->setCallbacks([ //set fullcalendar callback options (will not be JSON encoded)
'viewRender' => 'function() {alert("Callbacks!");}'
]);
return view('pages.schedule.schedule-book', compact('calendar'));
I am able to get Events from DB all works perfect!
Except, I cannot figure out how I should store *resources * and get them from DB in this format
'resources' => [
[ 'id' => '1',
'room' => '1. Flor',
'title' => 'Table No.: 1'
],
[ 'id' => '2',
'room' => '1. Flor',
'title' => 'Table No.: 2'
],
[ 'id' => '3',
'room' => '2. Flor',
'title' => 'Table No.: 1'
],
[ 'id' => '4',
'room' => '2. Flor',
'title' => 'Table No.: 2'
],
[ 'id' => '5',
'room' => '2. Flor',
'title' => 'Table No.: 3'
],
],
Can you please suggest something?
Thanks in advance :)
My idea was to have in DB room and each room has max_tables field and from that generates how many tables are needed.
Argument 1 passed to MaddHatter\LaravelFullcalendar\Calendar::addEvent() must implement interface MaddHatter\LaravelFullcalendar\Event, null given,
Hello
Your method "Calendar::addEvent" can be use only eloquent
Please Suggesting how to add custom array
-> addEvent( [
'title' => $event->title, //event title
'allDay' => true,
'start' => $event->startTime,
'end' => $event->endTime,
'id' => $event->id,
'color' => 'red'
]);
When I use with mongodb "Calendar::addEvent" method is not support MongoDate
Error is
FatalErrorException in EventCollection.php line 39:
Call to undefined method MongoDate::format()
the "Calendar::event" method is not support custom attribute
public static function event($title, $isAllDay, $start, $end)
thank you so much.
cj.
Displaying one calendar works fine but when attempting to show two separate calendars it only displays once. Taking a look at the generated code, it seems that it is naming both calendars the same name - whether I let the package automatically choose the name or even setting the id via setId()...it still chooses the same name for both.
Is there a workaround to this?
Hi, Thanks for the nice package.
I've followed your document, I set some events only.
The view render but there is no header for calendar such as : next,prev ,....
I saw the fullcalendar script render with these options, so I cannot figure out the problem. Please help.
I can see that full calendar supports integration for Google Calendar at http://fullcalendar.io/docs/google_calendar/ . Yet cannot find such integration in this package.
Using Laravel 5,
Getting this issue when trying to follow the docs.
Non-static method MaddHatter\LaravelFullcalendar\Calendar::addEvents() should not be called statically, assuming $this from incompatible context
how to add draggable event like this : http://fullcalendar.io/js/fullcalendar-2.4.0/demos/external-dragging.html
how do I set a repeating event?
example for a holiday.
Your documentation is confusing.
"Events" can be confused with Laravel Events.
You call models interfaces.
The documentation as a whole does not take you from start to finish. E.g., perhaps include a sample migration to make the event_models
table:
class CreateEventModelsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('event_models', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->boolean('all_day');
$table->datetime('start');
$table->datetime('end');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('event_models');
}
}
am trying to change the font color, what option should i pass
Inside FC docs there is option for events like
Multiple Resources
events: [
{
id: '1',
resourceIds: ['a', 'b'],
title: 'Meeting',
start: '2015-02-14'
}
]
So I can put one event in all resourcces using array and resource ID.
So I tried and it worked only if there is just one id inside array.
When I put two ID's inside array, event desipares.
$events[] = \Calendar::event(
'Event One', //event title
false, //full day event?
'2016-07-26T1100', //start time (you can also use Carbon instead of DateTime)
'2016-07-26T1600', //end time (you can also use Carbon instead of DateTime)
0,
[
'resourceId' => [1,2]
]
);
$events[] = \Calendar::event(
"Valentine's Day", //event title
true, //full day event?
new \DateTime('2016-07-25T1300'), //start time (you can also use Carbon instead of DateTime)
new \DateTime('2016-07-25T1600'), //end time (you can also use Carbon instead of DateTime)
1,
[
'resourceId' => 1,
]
);
Second event shows up, first does not show up :(
Could anybodey give me a hint?
Hi,
I'm trying all they to make this callendar work, but i cant do that. First, what tables or migration i have to make for this module?
At the end of the process in read me file, i get this issue: ErrorException in 5533aaacf4ee07b4096d657b48e1cecb line 66:
Undefined variable: calendar,
In the controller, i get error - Undifined class Calendar. I try all namespaces and use, but nothing worked for me.
Thanks for help,
Best regards
I implemented the functionality to delete events from a popup window and I want to refresh the calendar without having to refresh the page, but so far haven't succeeded.
On the setCallbacks
I added an eventClick
to the events so that a popup appears after I click an event. If the user clicks yes, the event is deleted and I try to refresh the calendar, by following the official docs, calling this function:
function refreshCalendar() {
var calendar_id = $("div[id^=calendar-]").attr('id');
$('#' + calendar_id).fullCalendar('refetchEvents'); <---
}
Everything works except the .fullCalendar('refetchEvents')
part, which doesn't seem to have any effect.
Do I have to do it in a specific way for it to work with laravel-fullcalendar or am I doing it incorrectly?
Thanks.
Hi,
Does the full calendar require a table? I was getting error so I created a table named 'event_models'.
Is it correct way or there is a another way round.
The calendar started working then. Now, the calendar shows those events that are written in the controller. What should I do if I have to add a new event to calendar that will be saved to database and showed on the calendar. How can I get the added event into a json so that I can store it.
I am doing this in laravel 5, I have just started using it.
I am getting this error
ErrorException in Calendar.php line 142:
Argument 1 passed to MaddHatter\LaravelFullcalendar\Calendar::addEvent() must implement interface MaddHatter\LaravelFullcalendar\Event, null given, called in C:\wamp\www\musicCentral\app\Http\Controllers\AgendaController.php on line 69 and defined
I have used the example code
How can I fix this?
I did all by your instrucitons but i am getting a blank page, not even any error.
RUn composer, added prover and alias, added code on proper place.
Also this is quite confusing: "You will also need to include fullcalendar.io's files in your HTML."
What files? I see that you are including js and css in your example.
Anyway, any idea what and how i can debug it?
$calendar = \Calendar::addEvents($events,[ 'color' => '#a0d3e8','url' => 'http://full-calendar.io','editable'=>true ])
->addEvents($events1,['color'=>'red','editable'=>false])
->setOptions([
'firstDay' => 1,
'editable' => true,
'droppable' => true,
'header' => array('left' => 'prev,next today', 'center' => 'title', 'right' => 'year,month,basicWeek,basicDay')
])->setCallbacks([
'viewRender' => 'function() {
console.log("sad");
}'
]);
return view('calendartest', compact('calendar'));
right => year
but not show year in view
https://github.com/Paulmicha/fullcalendar/blob/master/tests/year-view-test-01.html
I'm using draggable events - they get inserted to my DB just fine with an auto-incremented ID. Even after refreshing the page, the calendar pulls in the event(s) but none of my events have an ID - they are all "null."
I followed your docs and got the error Non-static method addevents should not be called statically...
Referring to issue #15 I used the Facades Class and it then gives me the error "Class laravel-fullcalendar does not exist" Do you have an advice for that?
Thanks!
Hello, my question is how to get events from DB in to this format
$events = [];
$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)
0 //optionally, you can specify an event ID
);
$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)
'stringEventId' //optionally, you can specify an event ID
);
Would this work?
$eloquentEvents = EventModel::all();
$calendar = \Calendar::addEvents($eloquentEvents)
->setOptions([
'firstDay' => 1
]);
return view('schedule', compact('calendar'));
EDITED:
I wanted this view (http://fullcalendar.io/js/fullcalendar-2.3.2/demos/basic-views.html). To be able to achieve this, add media="print" in stylesheet
I'm quite new to Laravel so I might be doing this all wrong, but I can't seem to get the calendar displayed. I keep getting the error 'Undefined variable: calendar (View: /home/vagrant/Code/Laravel/resources/views/pages/calendar.blade.php)'
I made a stackoverflow question with all the code here:
http://stackoverflow.com/questions/30662238/cannot-get-fullcalendar-to-work-laravel-5
Mind helping me out?
Thanks,
Cedric
I was trying to add support for another language when I found out the package does not support that!
Hi I tried to get all the events from my database using foreach
the Evant
implement MaddHatter\LaravelFullcalendar\Event
$eloquentEvent = Evant::all(); //EventModel implements MaddHatter\LaravelFullcalendar\Event
$events = [];
foreach ($eloquentEvent as $ge) {
$events[] = Calendar::event(
$ge->title, //event title
false, //full day event?
$ge->start_time, //start time (you can also use Carbon instead of DateTime)
$ge->end_time //end time (you can also use Carbon instead of DateTime)
);
}
$calendar = Calendar::addEvents($events);
return View::make('admin.event.view', compact('calendar'));
it's working OK, but can't find a way to pass the url and color for each event.
or
can you please suggest me a better way to do this
First of all, thanks for this package. Works really nice, but I'm running into a problem which I can't figure out.
I'm adding events to a calendar as an array. There are three types of events:
Here's the code in my controller:
public function getCalendar()
{
$user = Auth::user();
// get the projects to which the user has been invited
$projects = ProjectUser::where('user_id', $user->id )->get();
$invited_events = [];
$accepted_events = [];
$approved_events = [];
foreach( $projects as $event )
{
// only get the events where the admin_status hasn't been set yet
if( !isset($event->admin_status_id) ){
switch( $event->status_id ){
// invite has been sent to the freelancer, but hasn't been accepted
case 1:
array_push( $invited_events, \Calendar::event(
$event->project->name,
false,
$event->project->date_event_from,
$event->project->date_event_till,
$event->project->id
)
);
break;
// invite has been accepted by the freelancer
case 2:
array_push( $accepted_events, \Calendar::event(
$event->project->name,
false,
$event->project->date_event_from,
$event->project->date_event_till,
$event->project->id
)
);
break;
}
} elseif( $event->admin_status_id === 1 ){
// freelancer has been approved by brok decor
array_push( $approved_events, \Calendar::event(
$event->project->name,
false,
$event->project->date_event_from,
$event->project->date_event_till,
$event->project->id
)
);
}
}
$calendar = \Calendar::addEvents(
$invited_events, [ 'color' => '#a0d3e8' ]
)->addEvents(
$accepted_events, [ 'color' => '#f08a24' ]
)->addEvents(
$approved_events, [ 'color' => '#43ac6a' ]
)->setOptions([
'firstDay' => 1, // set Monday as first day of the week
'timeFormat' => 'H:mm',
'axisFormat' => 'H:mm'
]);
return view('extranet.calendar')->with([
'calendar' => $calendar
]);
}
What I want to do, is make the event clickable in the calendar, so the user is directed to the detailpage of the event (with all information about that event).
The url should be '/extranet/projects/{id}'.
I have tried adding an extra property to Calendar::event()
which didn't work (obviously, because it's not a method of MaddHatter\LaravelFullcalendar\Event
)
I have tried adding url
as property, the same way as color
is added in addEvents
, but that didn't work either because I don't know how to get the ID of the event from the $invited_events
,$accepted_events
or $approved_events
.
Help?
when I add new event it appears as 12a how can I render it to 12 am
here is my code
foreach ($eloquentEvent as $ge) {
$events[] = Calendar::event(
$ge->title, //event title
false, //full day event?
$ge->start_time, //start time (you can also use Carbon instead of DateTime)
$ge->end_time, //end time (you can also use Carbon instead of DateTime)
1,
[
'url' => 'event-details/' . $ge->id,
'color' => 'red',
]
);
}
Here is my error
Uncaught ReferenceError: $ is not defined(anonymous function) @ schedule:499
My layout file
@extends('layouts.app_backend')
@section('Specific-Page-Vendor-CSS')
<!-- Jquery -->
<link href="{{ asset('assets/vendor/fullcalendar/fullcalendar.css') }}" rel='stylesheet' />
<link href="{{ asset('assets/vendor/fullcalendar-scheduler/scheduler.css') }}" rel='stylesheet' />
@stop
@section('content')
<div class="container">
<div class="row">
{!! $calendar->calendar() !!}
{!! $calendar->script() !!}
</div>
</div>
@stop
@section('scripts')
<script src="{{ asset('assets/vendor/moment/moment.js') }}"></script>
<script src="{{ asset('assets/vendor/jquery-ui-1.11.4.custom/jquery-ui.js') }}"></script>
<script src="{{ asset('assets/vendor/fullcalendar/fullcalendar.js') }}"></script>
<script src="{{ asset('assets/vendor/fullcalendar-scheduler/scheduler.js') }}"></script>
@stop
What I get in html from inspecting element
<div id="calendar-X7znuCX7"></div>
<script>
$(document).ready(function(){
$('#calendar-X7znuCX7').fullCalendar({"header":{"left":"prev,next today","center":"title","right":"month,agendaWeek,agendaDay"},"eventLimit":true,"firstDay":1,"viewRender":function() {alert("Callbacks!");},"events":[{"id":0,"title":"Event One","allDay":false,"start":"2015-02-11T08:00:00+00:00","end":"2015-02-12T08:00:00+00:00"}]});
});</script>
Please let me know where could be ishue
Thanks you in advance
Example
$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)
'2015-02-14' //end time, must be a DateTime object or valid DateTime format
(http://bit.ly/1z7QWbg),
1 //optional event ID
);
But LaravelFullcalendar/Calendar.php dont have support id
public static function event($title, $isAllDay, $start, $end)
{
return new SimpleEvent($title, $isAllDay, $start, $end);
}
but SimpleEvent is supporting
public function __construct($title, $isAllDay, $start, $end, $id = null)
The model (not the interface, as you say) should extend the Eloquent\Model, rather than just Eloquent.
e.g.
namespace App;
use Illuminate\Database\Eloquent\Model;
class EventModel extends Model implements \MaddHatter\LaravelFullcalendar\IdentifiableEvent
{
}
I can not figure how to thatget
'#calendar-VxnJa0Rz'
Last part of calendar it all the time generates automatically
$('#calendar-??????').fullCalendar('updateEvent',event);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.