您好我MaddHatter\LaravelFullcalendar\Calendar
有问题。我已经尝试查看文档并在stackoverflow中搜索其他问题,但仍然没有找到解决方案。
这是我的错误:
类型错误:参数1传递给 MaddHatter \ LaravelFullcalendar \ Calendar :: addEvent()必须实现 接口MaddHatter \ LaravelFullcalendar \ Event,给定的数组,调用 d:\ XAMPP \ htdocs中\ ISEI \供应商\ laravel \框架的\ src \照亮的\ Support \外立面\ Facade.php 在第221行
EventController:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\EventModel;
use App\Branch;
use Calendar;
use MaddHatter\LaravelFullcalendar\Event;
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 Illuminate\Database\Eloquent\Model;
class EventModel extends Model implements \MaddHatter\LaravelFullcalendar\IdentifiableEvent
{
protected $table = 'event';
protected $fillable = [
'id_branch','title','start_date','end_date'
];
public function cabang()
{
return $this->hasOne('App\Branch', '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;
}
}
答案 0 :(得分:0)
尝试更改:
use MaddHatter\LaravelFullcalendar\Event;
在您的EventController
上
use MaddHatter\LaravelFullcalendar\Facades\Calendar;
答案 1 :(得分:0)
将 s 添加到 addEvent
$calendar = \Calendar::addEvents($event);