非静态方法MaddHatter \ LaravelFullcalendar \ Calendar :: addEvents()不应静态调用
我尝试使用
* composer dump-autoload
* php artisan cache:clear
* php artisan config:clear
没有帮助
EventsController.php
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Validator;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use App\Event;
use MaddHatter\LaravelFullcalendar\Calendar;
class EventsController extends Controller
{
public function index(){
$events = Event::get();
$event_list = [];
foreach ($events as $key => $event) {
$event_list[] = Calendar::event(
$event->event_name,
true,
new \DateTime($event->start_date),
new \DateTime($event->end_date.' +1 day')
);
}
$calendar_details = Calendar::addEvents($event_list);
return view('events', compact('calendar_details') );
}
Calendar.php
public function addEvents($events, array $customAttributes = [])
{
foreach ($events as $event) {
$this->eventCollection->push($event, $customAttributes);
}
return $this;
}
有人可以帮我吗?
答案 0 :(得分:0)
您需要先创建日历实例
更改:
$calendar_details = Calendar::addEvents($event_list);
return view('events', compact('calendar_details') );
收件人:
$calendar_details = new Calendar($your_construction_parameters);
$calendar_details->addEvents($event_list);
return view('events', compact('calendar_details'));