Hi guys,
It seems a strange question, I have 2 functions, the first function pull the data from the DB which is fine, the second function does a calculation based on current date and departure date, now the departuredate exist within the first function.
My question is how can I access departuredate from first function into the second one?
first function:
private function get_view($from, $to)
{
$Reports = DB::table('create_vouchers')->whereNull('create_vouchers.deleted_at')
->select('create_vouchers.id', 'client_name', 'night', 'hotels.hotel_name', 'arrivaldate', 'departuredate', 'total_amount', 'number_of_room', 'payment_mode')
->join('hotels', 'hotels.id', 'create_vouchers.hotel_name_id')
->whereBetween('arrivaldate', [$from, $to])->get();
return view('admin.vouchersAccountings.index', compact('Reports', 'from', 'to'));
}
Second function:
public function getStatus()
{
$CurrentDay = Carbon::today()->format(config('panel.date_fomat'));
$DepartureDate = DB::table('create_vouchers.departuredate');
if ($CurrentDay >= $DepartureDate) {
return "S";
} else {
return "D";
}
}