I'm trying to get results from the database put them in an array, get them via javascript and check if a value is set.
CalendarController.php
public function tasks($id)
{
$tasks = task::Findtasks()->select('tasks.*', 'tasks_times.*', 'tasks.name as title')
->where('project_id', '=', $id)
->join('tasks_times', 'tasks.id', '=', 'tasks_times.task_id')
->get();
return view('testcalendar', compact('tasks'));
}
as you can see i'm giving tasks to the view..
Now i have this piece of javascript script in a script tag on the "testcalendar" view.
eventAfterRender: function (event, element, view) {
var dataHoje = new Date();
var completed = <?php echo json_encode($tasks); ?>;
var tasks = JSON.parse('<?php echo json_encode($tasks); ?>')
for (var i = 0; i < completed.length; i++) {
if (completed[i]['completed'] == 3) {
//event.color = "Groenoe";
element.css('background-color', '#0eb505');
} else if (event.start < dataHoje && event.end < dataHoje) {
//event.color = "Rood";
element.css('background-color', '#fc0000');
} else if (event.start > dataHoje && event.end > dataHoje) {
//event.color = "Blauw";
element.css('background-color', '#27bec6');
}
}
},
so when "completed" = 3 i want the background-color to turn green. (Yes completed is a column in the database) if it's not 3 then it's need to be a diffrent color ofcourse.
Thank you x