pagination, orderby 'desc', filter: fromDate, toDate, status, type, name } public function createTicket(Request $request){ //Get data from request $startDate = $request->input('start_date'); //Start day $startPeriod = $request->input('start_period'); //The session begins $endDate = $request->input('end_date'); //End date $endPeriod = $request->input('end_period'); //Session ends $user_id = $request->input('user_id'); // ID user create ticket $results = $this->getAllPeriod($startDate, $startPeriod, $endDate, $endPeriod); } public function deleteTicket(Request $request){ $user = auth('admins')->user(); $ticket_id = $request->input('ticket_id'); // $user->id == user_id of ticket ---> delete // else false } public function handleTicket(Request $request){ $ticket_id = $request->input('ticket_id'); $admin_note = $request->input('admin_note'); $action = $request->input('action'); // 'confirm' or 'refuse' $admin = auth('admins')->user(); // $admin->id != user_id of ticket ---> continue // Confirm // Add records to the notes table like function Timekeeping.addNoteForUser() based on the $results array // Update updated_by and admin_note in tickets table // Send notification email to admin (list) and users // Refuse // Update updated_by and admin_note in tickets table // Send notification email to admin (list) and users // false } private function getAllPeriod($startDate, $startPeriod, $endDate, $endPeriod) { //Create an array to contain the results $results = []; //Use CarbonPeriod to create a period from the start date to the end date $period = CarbonPeriod::create($startDate, $endDate); foreach ($period as $date) { //If it is the start date if ($date->isSameDay($startDate)) { //Add start session $results[] = ['date' => $date->toDateString(), 'period' => $startPeriod]; //If the start date is morning, add afternoon if ($startPeriod == 'morning') { $results[] = ['date' => $date->toDateString(), 'period' => 'afternoon']; } } elseif ($date->isSameDay($endDate)) { //If it is the end date //If the end session is afternoon, add morning first if ($endPeriod == 'afternoon') { $results[] = ['date' => $date->toDateString(), 'period' => 'morning']; } $results[] = ['date' => $date->toDateString(), 'period' => $endPeriod]; } else { //Add both sessions for days between intervals $results[] = ['date' => $date->toDateString(), 'period' => 'morning']; $results[] = ['date' => $date->toDateString(), 'period' => 'afternoon']; } } //Returns results return $results; } }