Laravel 5.1 FullCalendar table



我正试图使用此包将FullCalendar实现到我的Laravel项目https://github.com/maddhatter/laravel-fullcalendar我已经创建了我的模型:EventModel.php

<?php
namespace App;
use IlluminateDatabaseEloquentModel;
class EventModel extends Model implements MaddHatterLaravelFullcalendarEvent
{
    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 MaddHatterLaravelFullcalendarEvent
    $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*fromevent_models极限1)

我必须加一张桌子吗?

跟随你的心,不,我开玩笑,跟随你的模型函数:

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;
    }

在那里你可以看到你需要一个id和一个title,一个是int,另一个是string。:)

相关内容

  • 没有找到相关文章

最新更新