mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 02:39:10 -04:00
New Model for Event,Booking and Course
This commit is contained in:
@@ -57,56 +57,34 @@ class ScheduleController extends Controller
|
||||
|
||||
public function apiIndex()
|
||||
{
|
||||
$schedules = Schedule::all();
|
||||
$activity = \App\ComplementaryActivity::all();
|
||||
$start = substr(request()->start,0,10);
|
||||
$end = substr(request()->end,0,10);
|
||||
$allschedules = Schedule::all();
|
||||
|
||||
$allevents = \App\Event::all();
|
||||
$events = [];
|
||||
$jsonevents = [];
|
||||
$schedules = [];
|
||||
|
||||
foreach ($allschedules as $schedule) {
|
||||
if($schedule->date >= $start && $schedule->date <= $end) {
|
||||
array_push($schedules,$schedule);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($allevents as $event) {
|
||||
if($event->date_begin >= $start && $event->date_begin <= $end) {
|
||||
array_push($events,$event);
|
||||
}
|
||||
if($event->date_end >= $start && $event->date_end <= $end) {
|
||||
array_push($events,$event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach ($schedules as $schedule) {
|
||||
$color = 'blue';
|
||||
switch ($schedule->type) {
|
||||
case 'regular':
|
||||
$color = 'orange';
|
||||
break;
|
||||
|
||||
case 'pilotage':
|
||||
$color = '#58D3F7';
|
||||
break;
|
||||
|
||||
case 'drill':
|
||||
$color = 'blue';
|
||||
break;
|
||||
|
||||
case 'music':
|
||||
$color = 'green';
|
||||
break;
|
||||
|
||||
case 'biathlon':
|
||||
$color = 'red';
|
||||
break;
|
||||
|
||||
case 'marksmanship':
|
||||
$color = 'grey';
|
||||
break;
|
||||
|
||||
case 'founding':
|
||||
$color = '#00FF40';
|
||||
break;
|
||||
|
||||
case 'volunteer':
|
||||
$color = '#DF0174';
|
||||
break;
|
||||
|
||||
case 'other':
|
||||
$color = '#DF0174';
|
||||
break;
|
||||
|
||||
default:
|
||||
if ($activity->find($schedule->type)) {
|
||||
$color = $activity->find($schedule->type)->calendar_color;
|
||||
}
|
||||
break;
|
||||
};
|
||||
|
||||
$color = $this->getColor($schedule->type);
|
||||
|
||||
$event = [
|
||||
'title' => $schedule->data['event_name'],
|
||||
@@ -115,14 +93,83 @@ class ScheduleController extends Controller
|
||||
'color' => $color,
|
||||
'id' => $schedule->id
|
||||
];
|
||||
array_push($events,$event);
|
||||
array_push($jsonevents,$event);
|
||||
}
|
||||
|
||||
return json_encode($events);
|
||||
foreach ($events as $event) {
|
||||
|
||||
$color = $this->getColor($event->type);
|
||||
|
||||
$myevent = [
|
||||
'title' => $event->name,
|
||||
'start' => $event->date_begin,
|
||||
'end' => $event->date_end,
|
||||
'color' => $color,
|
||||
'id' => $event->id
|
||||
];
|
||||
array_push($jsonevents,$myevent);
|
||||
}
|
||||
|
||||
return json_encode($jsonevents);
|
||||
}
|
||||
|
||||
public function loadModal($id)
|
||||
{
|
||||
return view('public.modal.schedule',['event' => \App\Schedule::find($id)]);
|
||||
}
|
||||
|
||||
public function loadModalFull($id)
|
||||
{
|
||||
return view('admin.schedule.modal.show',['event' => \App\Schedule::find($id)]);
|
||||
}
|
||||
|
||||
public function getColor($type)
|
||||
{
|
||||
$activity = \App\ComplementaryActivity::all();
|
||||
$color = 'blue';
|
||||
switch ($type) {
|
||||
case 'regular':
|
||||
$color = 'orange';
|
||||
break;
|
||||
|
||||
case 'pilotage':
|
||||
$color = '#58D3F7';
|
||||
break;
|
||||
|
||||
case 'drill':
|
||||
$color = 'blue';
|
||||
break;
|
||||
|
||||
case 'music':
|
||||
$color = 'green';
|
||||
break;
|
||||
|
||||
case 'biathlon':
|
||||
$color = 'red';
|
||||
break;
|
||||
|
||||
case 'marksmanship':
|
||||
$color = 'grey';
|
||||
break;
|
||||
|
||||
case 'founding':
|
||||
$color = '#00FF40';
|
||||
break;
|
||||
|
||||
case 'volunteer':
|
||||
$color = '#DF0174';
|
||||
break;
|
||||
|
||||
case 'other':
|
||||
$color = '#DF0174';
|
||||
break;
|
||||
|
||||
default:
|
||||
if ($activity->find($type)) {
|
||||
$color = $activity->find($type)->calendar_color;
|
||||
}
|
||||
break;
|
||||
};
|
||||
return $color;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user