【发布时间】:2016-04-13 20:02:47
【问题描述】:
我正在尝试使用这个包 https://github.com/maddhatter/laravel-fullcalendar 在我的 Laravel 项目中实现 FullCalendar 我已经创建了我的模型: EventModel.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class EventModel extends Model implements \MaddHatter\LaravelFullcalendar\Event
{
protected $dates = ['start', 'end'];
/**
* Get the event's id number
*
* @return int
*/
public function getId() {
return $this->id;
}
/**
* Get the event's title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Is it an all day event?
*
* @return bool
*/
public function isAllDay()
{
return (bool)$this->all_day;
}
/**
* Get the start time
*
* @return DateTime
*/
public function getStart()
{
return $this->start;
}
/**
* Get the end time
*
* @return DateTime
*/
public function getEnd()
{
return $this->end;
}
}
和我的控制器:
public function calendario() {
$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
);
$eloquentEvent = EventModel::first(); //EventModel implements MaddHatter\LaravelFullcalendar\Event
$calendar = \Calendar::addEvents($events) //add an array with addEvents
->addEvent($eloquentEvent, [ //set custom color fo this event
'color' => '#800',
])->setOptions([ //set fullcalendar options
'firstDay' => 1
])->setCallbacks([ //set fullcalendar callback options (will not be JSON encoded)
'viewRender' => 'function() {alert("Callbacks!");}'
]);
return view('hello', compact('calendar'));
}
但是当我去我的路线时我得到了这个错误:
SQLSTATE[42S02]:未找到基表或视图:1146 表 'petdate.event_models' 不存在(SQL: select * from
event_models限制 1)
我必须添加表格吗?
【问题讨论】:
-
错误说必须存在一个表,所以是的,你必须添加一个表。
-
但是表格需要哪些字段?
标签: php laravel eloquent fullcalendar laravel-5.1