Я пытаюсь реализовать FullCalendar в Laravel. В этом отношении мой контроллер выглядит так, как показано ниже
<?php
namespace App\Http\Controllers;
use Illuminate\Routing\Controller as BaseController;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Calendar;
use App\Event;
class HomeController extends BaseController
{
public function calendar() {
$events = [];
$data = Event::all();
if($data->count()) {
foreach ($data as $key => $value) {
$events[] = Calendar::event(
$value->title,
true,
new \DateTime($value->start_date),
new \DateTime($value->end_date.' +1 day'),
null,
// Add color and link on event
[
'color' => '#f05050',
'url' => 'pass here url and any route',
]
);
}
}
$calendar = Calendar::addEvents($events);
return view('welcome', compact('calendar'));
}
}
Мой файл просмотра, как показано ниже
<!doctype html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="{{ asset('/css/main.css')}}" />
<script src="https://cdn.jsdelivr.net/npm/fullcalendar@5.2.0/main.min.js" crossorigin="anonymous"></script>
<style>
body {
margin: 40px 10px;
padding: 0;
font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
font-size: 14px;
}
#calendar {
max-width: 1100px;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="container">
<div class="panel panel-primary">
<div class="panel-heading">MY Calender</div>
<div class="panel-body">
{!! $calendar->calendar() !!}
{!! $calendar->script() !!}
</div>
</div>
</div>
</body>
</html>
Мой результат такой, как показано ниже (у меня пустой белый экран)
I found that I have to initialize FullCalendar. How can I initialize FullCalender ?
I am trying to follow below tutorials. But I didn't find any initialization there.
https://www.laravelcode.com/post/laravel-full-calendar-tutorial-example-using-maddhatter-laravel-fullcalendar
https://github.com/acaronlex/laravel-calendar
https://github.com/maddhatter/laravel-fullcalendar
https://hdtuto.com/article/laravel-full-calendar-tutorial-example-from-scratch
Я запуталась. Что делать?