Laravel 5.4实现接口MADDHATTER LARAVELFULLCALENDAR 日历错误



你好,我对MaddHatterLaravelFullcalendarCalendar有问题。我已经尝试在stackoverflow中的其他问题中查看文档和搜索,但仍然找不到解决方案。

这是我的eror:

类型错误:参数1传递给 maddhatter laravelfullcalendar calendar :: addevent()必须实现 接口maddhatter laravelfullcalendar event,Array给出,调用 D: Xampp htdocs isei vendor laravel framework src src Illuminate support support facades facade facade facade.php 在第221行

EventController:

<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
use AppEventModel;
use AppBranch;
use Calendar;
use MaddHatterLaravelFullcalendarEvent;
class EventController extends Controller
{
  public function getIndex()
  {
     $event = [];
     $data = EventModel::all();
     if($data->count())
     {
        foreach ($data as $key => $value)
        {
          $event[] = Calendar::event(
              $value->title,
              true,
              new DateTime($value->start_date),
              new DateTime($value->end_date.' +1 day')
          );
        }
     }
    $calendar = Calendar::addEvent($event);
    return view('event', compact('calendar'));
  }
}

事件模型:

<?php
namespace App;
use IlluminateDatabaseEloquentModel;
class EventModel extends Model implements MaddHatterLaravelFullcalendarIdentifiableEvent
{
  protected $table = 'event';
  protected  $fillable = [
    'id_branch','title','start_date','end_date'
  ];
  public function cabang()
  {
    return $this->hasOne('AppBranch', 'id', 'id_branch');
  }
  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;
    }
}

尝试更改:

use MaddHatterLaravelFullcalendarEvent;

在您的EventController上:

use MaddHatterLaravelFullcalendarFacadesCalendar;

添加s到addevent

$calendar = Calendar::addEvents($event);

相关内容

  • 没有找到相关文章

最新更新