I am using CodeIgniter 4. I want to do this Full Calendar, I followed evry step in the tutorial
**ErrorException Undefined variable $data **
This is my View File
<div class="container">
<h1>Codeigniter Fullcalendar</h1>
<div class="row" style="width:50%">
<div class="col-md-12">
<div id="calendar"></div>
</div>
</div>
</div>
<script type="text/javascript">
var events = <?php echo json_encode($data) ?>;
var date = new Date()
var d = date.getDate(),
m = date.getMonth(),
y = date.getFullYear()
$('#calendar').fullCalendar({
header : {
left : 'prev,next today',
center: 'title',
right : 'month,agendaWeek,agendaDay'
},
buttonText: {
today: 'today',
month: 'month',
week : 'week',
day : 'day'
},
events : events
})
</script>
This is my Controller
public function index() {
$db = \Config\Database::connect();
$builder = $db->table('calendar');
$query = $builder->select('*')
->limit(10)->get();
$data = $query->getResult();
foreach ($data as $key => $value) {
$data['data'][$key]['title'] = $value->title;
$data['data'][$key]['start'] = $value->start_date;
$data['data'][$key]['end'] = $value->end_date;
$data['data'][$key]['backgroundColor'] = "#00a65a";
}
return view('calendar', $data);
}
Iam using C14, and try to use full calendar in my project. But this happens when I try this code for Full Calendar. Can someone help