public function filter(Request $request) { $data_filter = $request->all(); $date_from = $data_filter['date_from']; $date_to = $data_filter['date_to']; $hour_from = "00:01"; $hour_to = "23:59"; $time_from = $this->convert_datetime($date_from, $hour_from); $time_to = $this->convert_datetime($date_to, $hour_to); if ($data_filter['booking_code'] == '') { $credits = Credit::where('time_book', '>=', $time_from)->where('time_book', '<=', $time_to)->get(); } else { $credits = Credit::where('booking_code', $data_filter['booking_code'])->get(); } return view('backend.credit.index', compact('credits', 'data_filter')); }
/** * Gets the number of trade credits for a user * * @param User $user * @return Integer */ public function searchUserCreditAmount(User $user) { return Credit::where('user_id', $user->id)->first(); }
public function credits(Request $request) { $service_out = []; $key = 0; $service_bf = 0; $service_af = 0; //$services = Service::all(); $time = time(); $data = $request->all(); $data_fn = ["name_card" => $data['name_card'], "type_card" => $data['type_card'], "number_card" => $data['number_card'], "cc_mont" => $data['cc_mont'], 'cc_year' => $data['cc_year'], 'cvc_card' => $data['cvc_card'], 'booking_code' => $data['booking_code'], 'time_book' => $time]; $credit_old = Credit::where("booking_code", $data['booking_code'])->get(); //return $data['booking_code']; if (count($credit_old) == 0) { $credit = Credit::create($data_fn); } else { //return $data; DB::table('credits')->where('id', $credit_old[0]['id'])->update($data_fn); } $info_bookings = Booking::where('code_booking', $data['booking_code'])->get(); foreach ($info_bookings as $info_booking) { $info = $info_booking; } $services = DB::table('service_lang')->join('services', 'service_lang.service_id', '=', 'services.id')->where('service_lang.lang_id', current_lang_id())->select('service_lang.*', 'services.*')->get(); foreach ($services as $service) { if ($service->choice == 0) { $service_out[$key]['name'] = $service->name; if ($service->option == 0) { $ser_bf = $info['total_room'] * $service->value / 100; $service_bf += $ser_bf; $service_out[$key]['money'] = $ser_bf; } else { $service_bf += $service->value; $service_out[$key]['money'] = $service->value; } $key++; } } foreach ($services as $service) { if ($service->choice == 1) { $service_out[$key]['name'] = $service->name; if ($service->option == 0) { $ser_af = ($info['total_room'] + $service_bf) * $service->value / 100; $service_af += $ser_af; $service_out[$key]['money'] = $ser_af; } else { $service_af += $service->value; $service_out[$key]['money'] = $service->value; } $key++; } } //$services = array_reverse($service_out); //return $info; $lang = \Session::get('locale'); if (current_lang_id() == 1) { Mail::send('emails.visa', ['data' => $info, 'credit' => $data, 'services' => $service_out], function ($message) use($info) { $message->to($info['emails'], 'VATC SleepPod')->from('*****@*****.**')->subject('VATC SleepPod Yêu cầu đặt phòng.'); }); if (!is_null($info['guest_email']) && $info['guest_email'] != '') { Mail::send('emails.visa', ['data' => $info, 'credit' => $data, 'services' => $service_out], function ($message) use($info) { $message->to($info['guest_email'], 'VATC SleepPod')->from('*****@*****.**')->subject('VATC SleepPod Yêu cầu đặt phòng.'); }); } Mail::send('emails.visa', ['data' => $info, 'credit' => $data, 'services' => $service_out], function ($message) use($info) { $message->to('*****@*****.**', 'VATC SleepPod')->from('*****@*****.**')->subject('VATC SleepPod Yêu cầu đặt phòng.'); }); } else { Mail::send('emails.visa-en', ['data' => $info, 'credit' => $data, 'services' => $service_out], function ($message) use($info) { $message->to($info['emails'], 'VATC SleepPod')->from('*****@*****.**')->subject('VATC SleepPod Booking Information.'); }); if (!is_null($info['guest_email']) && $info['guest_email'] != '') { Mail::send('emails.visa-en', ['data' => $info, 'credit' => $data, 'services' => $service_out], function ($message) use($info) { $message->to($info['guest_email'], 'VATC SleepPod')->from('*****@*****.**')->subject('VATC SleepPod Booking Information.'); }); } Mail::send('emails.visa-en', ['data' => $info, 'credit' => $data, 'services' => $service_out], function ($message) use($info) { $message->to('*****@*****.**', 'VATC SleepPod')->from('*****@*****.**')->subject('VATC SleepPod Booking Information.'); }); } return view('layouts.booking.cc-notice', compact('info', 'data', 'service_out')); }