/**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     //
     parent::boot($router);
     /*Route::model*/
     /**
      * Route model binding altering default logic
      * $router->bind('articles',function($id){
      *     return \App\Article::published()->findOrFail($id);
      * });
      */
     /*Using wildcard*/
     /*$router->model('articles','App\Article');*/
     $router->bind('articles', function ($id) {
         return \App\Article::published()->findOrFail($id);
     });
     $router->bind('rates', function ($id) {
         return \App\Rate::where('id', $id)->firstOrFail();
     });
     $router->bind('customers', function ($id) {
         return \App\Customer::where('id', $id)->firstOrFail();
     });
     $router->bind('tags', function ($name) {
         return \App\Tag::where('name', $name)->firstOrFail();
     });
     $router->bind('motherboards', function ($name) {
         return \App\Motherboard::where('name', $name)->firstOrFail();
     });
 }
 /**
  * Get request from profile form and update the fields of the Customer instance.
  * Then redirect to their intended location or '/'
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function profileUpdate(UpdateProfileRequest $request)
 {
     // Retrieve all data in $request to an array
     $data = $request->all();
     // Find and retrieve the appropriate Customer instance
     $customer = Customer::where('email', Auth::user()->email)->first();
     // Update the details
     $customer->name = $data['name'];
     $customer->NIC_passport_num = $data['ID'];
     $customer->telephone_num = $data['telephone'];
     $customer->address_line_1 = $data['address_line1'];
     $customer->address_line_2 = $data['address_line2'];
     $customer->city = $data['city'];
     $customer->province_state = $data['province'];
     $customer->zip_code = $data['zipCode'];
     $customer->country = $data['country'];
     // Save the updated Customer instance
     $customer->save();
     //this lines are added, if the user is facebook logged in user he needs to fill his other details and he should be
     //redirected to payment page, since return redirect()->intended() is not working for this purpose
     if (Session::has('fblogin_payment')) {
         return redirect('payment');
     }
     return redirect()->intended('/')->with('success', 'Your details have been updated successfully.');
 }
Esempio n. 3
0
 public function single($mr, $currentMonth)
 {
     $actualVisits = [];
     $MonthlyCustomerProducts = [];
     $MRLine = [];
     $doctors = Customer::where('mr_id', $mr)->get();
     foreach ($doctors as $singleDoctor) {
         $actualVisits[$singleDoctor->id] = Report::where('mr_id', $mr)->where('month', $currentMonth)->where('doctor_id', $singleDoctor->id)->count();
         $MonthlyCustomerProducts[$singleDoctor->id] = Customer::monthlyProductsBought([$singleDoctor->id])->toArray();
     }
     $products = Product::where('line_id', Employee::findOrFail($mr)->line_id)->get();
     $coverageStats = Employee::coverageStats($mr, $currentMonth);
     $allManagers = Employee::yourManagers($mr);
     $totalProducts = Employee::monthlyDirectSales($mr, $currentMonth);
     $totalSoldProductsSales = $totalProducts['totalSoldProductsSales'];
     $totalSoldProductsSalesPrice = $totalProducts['totalSoldProductsSalesPrice'];
     $currentMonth = \Carbon\Carbon::parse($currentMonth);
     $lines = MrLines::select('line_id', 'from', 'to')->where('mr_id', $mr)->get();
     foreach ($lines as $line) {
         $lineFrom = \Carbon\Carbon::parse($line->from);
         $lineTo = \Carbon\Carbon::parse($line->to);
         if (!$currentMonth->lte($lineTo) && $currentMonth->gte($lineFrom)) {
             $MRLine = MrLines::where('mr_id', $mr)->where('line_id', $line->line_id)->get();
         }
     }
     $dataView = ['doctors' => $doctors, 'MonthlyCustomerProducts' => $MonthlyCustomerProducts, 'actualVisits' => $actualVisits, 'products' => $products, 'totalVisitsCount' => $coverageStats['totalVisitsCount'], 'actualVisitsCount' => $coverageStats['actualVisitsCount'], 'totalMonthlyCoverage' => $coverageStats['totalMonthlyCoverage'], 'allManagers' => $allManagers, 'totalSoldProductsSales' => $totalSoldProductsSales, 'totalSoldProductsSalesPrice' => $totalSoldProductsSalesPrice, 'MRLines' => $MRLine];
     return view('am.line.single', $dataView);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['subject' => 'required|max:255', 'product' => 'required', 'group' => 'required', 'severity' => 'required', 'description' => 'required']);
     $settings = Settings::where('name', 'ticket_track_id')->first();
     $track_id = $settings->str_value;
     $customer = Customer::where('id', $this->my_customer_id)->first();
     $search_strings = ['%COMPANY_NAME', '%Y', '%m', '%d'];
     $value_strings = [str_replace(' ', '_', $customer->name), date('Y', time()), date('m', time()), date('d', time())];
     $track_id = str_replace($search_strings, $value_strings, $track_id);
     $ticket = Ticket::create(['subject' => $request->subject, 'track_id' => $track_id, 'description' => $request->description, 'group_id' => $request->group, 'severity_id' => $request->severity, 'product_id' => $request->product, 'user_id' => $this->my_id, 'customer_id' => $this->my_customer_id, 'status_id' => 1]);
     if (isset($request->attachments)) {
         foreach ($request->attachments as $attachment) {
             // Check that the directory exists
             $uploadPath = storage_path() . '/attachments/' . $ticket->id;
             $fs = new Filesystem();
             if (!$fs->isDirectory($uploadPath)) {
                 // Create the directory
                 $fs->makeDirectory($uploadPath);
             }
             $attachment->move($uploadPath, $attachment->getClientOriginalName());
             $_attachment = Attachment::create(['user_id' => $this->my_id, 'name' => $attachment->getClientOriginalName(), 'ticket_id' => $ticket->id]);
         }
     }
     $this->dispatch(new EmailNewTicket($ticket));
     return redirect('/tickets');
 }
 public function stores()
 {
     $accounts = Account::all();
     $data = array();
     foreach ($accounts as $account) {
         $customers = Customer::where('account_id', $account->id)->get();
         $account_children = array();
         foreach ($customers as $customer) {
             $areas = Area::where('customer_id', $customer->id)->get();
             $customer_children = array();
             foreach ($areas as $area) {
                 $regions = Region::where('area_id', $area->id)->get();
                 $area_children = array();
                 foreach ($regions as $region) {
                     $distributors = Distributor::where('region_id', $region->id)->get();
                     $region_children = array();
                     foreach ($distributors as $distributor) {
                         $stores = Store::where('distributor_id', $distributor->id)->get();
                         $distributor_children = array();
                         foreach ($stores as $store) {
                             $distributor_children[] = array('title' => $store->store, 'key' => $account->id . "." . $customer->id . "." . $area->id . "." . $region->id . "." . $distributor->id . "." . $store->id);
                         }
                         $region_children[] = array('select' => true, 'title' => $distributor->distributor, 'isFolder' => true, 'key' => $account->id . "." . $customer->id . "." . $area->id . "." . $region->id . "." . $distributor->id, 'children' => $distributor_children);
                     }
                     $area_children[] = array('select' => true, 'title' => $region->region, 'isFolder' => true, 'key' => $account->id . "." . $customer->id . "." . $area->id . "." . $region->id, 'children' => $region_children);
                 }
                 $customer_children[] = array('select' => true, 'title' => $area->area, 'isFolder' => true, 'key' => $account->id . "." . $customer->id . "." . $area->id, 'children' => $area_children);
             }
             $account_children[] = array('select' => true, 'title' => $customer->customer, 'isFolder' => true, 'key' => $account->id . "." . $customer->id, 'children' => $customer_children);
         }
         $data[] = array('title' => $account->account, 'isFolder' => true, 'key' => $account->id, 'children' => $account_children);
     }
     return response()->json($data);
 }
Esempio n. 6
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $customer = Customer::where('id', $id)->orWhere('slug', $id)->firstOrFail();
     $snippets = $customer->snippets;
     $persons = $customer->persons;
     return view('customers.show', compact('customer', 'snippets', 'persons'));
 }
 public function userHistoric()
 {
     $user_id = Auth::user()->id;
     $customer_id = Customer::where('user_id', '=', $user_id)->value('id');
     $histories = History::where('customer_id', '=', $customer_id)->get();
     return view('front.user_historic', compact('histories'));
 }
Esempio n. 8
0
 public function search()
 {
     $products = Product::where('line_id', Employee::find(\Auth::user()->id)->line_id)->get();
     $doctors = Customer::where('mr_id', \Auth::user()->id)->get();
     $dataView = ['products' => $products, 'doctors' => $doctors];
     return view('mr.search.sales.search', $dataView);
 }
 public function getViewCustomer($id)
 {
     $customer = Customer::where("id", $id)->with("companies")->with("user")->with(['jobs' => function ($q) {
         $q->where("company_id", Auth::user()->company_id);
     }])->first();
     $total = Job::where("customer_id", $id)->count();
     return view("customer", ["customer" => $customer, "total" => $total]);
 }
 public function gymaccess($id)
 {
     $customer = \App\Customer::where('id', $id)->firstOrFail();
     /*$activationDate = Carbon::today();*/
     $activationDate = Carbon::today()->format('F d\\, Y');
     $rates = Rate::where('member_ind', $customer->membership_ind)->where('per_session_ind', '!=', 1)->lists('rate', 'id', 'price');
     return view('customers.gymaccess', compact('customer', 'rates', 'activationDate'));
 }
Esempio n. 11
0
 protected function userExists($data)
 {
     $customer = Customer::where('email', $data['email'])->first();
     if ($customer == '' || empty($customer)) {
         return false;
     } else {
         return true;
     }
 }
Esempio n. 12
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     if (Auth::user()->admin == 1) {
         $customer = Customer::findOrFail($id);
     } else {
         $customer = Customer::where('group', Auth::user()->group)->where('id', $id)->firstOrFail();
     }
     return view('customer.show', ['customer' => $customer]);
 }
Esempio n. 13
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //         return view('customer.show');
     $search = \Request::get('search');
     //<-- we use global request to get the param of URI
     $customers = Customer::where('name', 'like', '%' . $search . '%')->orderBy('name')->paginate(20);
     return view('customer.list', array('customers' => $customers));
     //     $customers = Customer::all();
     //       return view('customer.list', array('customers' => $customers));
 }
 public function customers()
 {
     $search = \Input::get('q');
     if ($search) {
         $customers = \App\Customer::where('firstname', 'like', $search . '%')->orWhere('lastname', 'like', $search . '%')->orderBy('created_at', 'desc')->paginate($this->limit);
     } else {
         $customers = \App\Customer::orderBy('created_at', 'desc')->paginate($this->limit);
     }
     return view('admin.pages.customers', compact('customers'));
 }
Esempio n. 15
0
 public function customers()
 {
     $term = \Input::get('term');
     $customers = Customer::where('customer_name', 'like', "%{$term}%")->orderBy('customer_name', 'asc')->get();
     $json = [];
     foreach ($customers as $c) {
         array_push($json, array('value' => $c->id, 'label' => $c->customer_name));
     }
     return response()->json($json);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function getEstimations()
 {
     if (!Auth::check()) {
         return Redirect::to("/");
     }
     $id = Auth::user()->id;
     $customer = Customer::where("user_id", $id)->with("user")->with("jobs")->first();
     $total = Job::where("customer_id", $id)->count();
     return view("customer.estimations", ["customer" => $customer, "total" => $total]);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $groups = Customer::where('id', $this->my_customer_id)->first()->groups()->get();
     $my_groups = [];
     foreach ($groups as $group) {
         $my_groups[] = $group->id;
     }
     //$tickets = Ticket::whereRaw('group_id in (' . implode(', ', $my_groups) . ')')->orderBy('updated_at', 'desc')->take(5)->get();
     $tickets = Ticket::whereIn('group_id', $my_groups)->where('status_id', '1')->orderBy('updated_at', 'desc')->take(5)->get();
     return view('layouts.dashboard.index', ['my_permissions' => $this->my_permissions, 'tickets' => $tickets]);
 }
Esempio n. 18
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($id)
 {
     $customer = Customer::where('id', $id)->firstOrFail();
     /* if customer is not authenticated */
     if ($customer->id != Auth::user()->id) {
         return redirect()->route("admin", Auth::user()->id);
     }
     $titles = Title::where('customer_id', Auth::user()->id)->orderBy('time', 'desc')->get();
     $allUsers = $this->getAllUsers($customer);
     return view("titles.index", compact('titles', 'allUsers', 'customer'));
 }
Esempio n. 19
0
 public function view($id)
 {
     $review = $this->customerReviewRepository->getById($id);
     if (!$review) {
         $review = new CustomerReview();
         $review->id = 0;
     }
     $products = AmazonProduct::all();
     $customers = Customer::where('user_id', '=', auth()->user()->id)->get();
     $content = View::make('reviews.modals.view', compact('review', 'products', 'customers'))->render();
     return $this->json->set('content', $content)->success();
 }
 public function update(Request $request)
 {
     $customerId = $request->input('customerId');
     $customer = Customer::where('id', $customerId)->first();
     if (isset($customer)) {
         $customer->name = $request->input('name');
         $customer->phone = $request->input('phone');
         $customer->save();
         return json_encode(array('message' => 'done', 'customer' => $customer));
     } else {
         return json_encode(array('message' => 'invalid'));
     }
 }
Esempio n. 21
0
 public function register($data)
 {
     Customer::where('email', $data['email'])->where('email_confirmed', false)->delete();
     $customer = new Customer(['email' => $data['email'], 'first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'password' => $data['password'], 'gender_id' => $data['gender_id']]);
     $customer->save();
     $invoice = ['email' => $data['email'], 'first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'gender_id' => $data['gender_id'], 'country_id' => config('shop.default_country_id')];
     $shipping = $invoice;
     $invoice['address_kind_id'] = config('shop.invoice_address_kind_id');
     $shipping['address_kind_id'] = config('shop.shipping_address_kind_id');
     $invoice_address = new CustomerAddress($invoice);
     $shipping_address = new CustomerAddress($shipping);
     $customer->customer_addresses()->saveMany([$invoice_address, $shipping_address]);
     return $customer;
 }
Esempio n. 22
0
 public function confirm($confirmation_code)
 {
     if (!$confirmation_code) {
         throw \App::abort(404);
     }
     $customer = \App\Customer::where('confirmation_code', $confirmation_code)->first();
     if (!$customer) {
         throw \App::abort(404);
     }
     $customer->active = 1;
     $customer->confirmed = 1;
     $customer->confirmation_code = null;
     $customer->save();
     return redirect()->route('login', \Lang::get('url')['login'])->with('alert-success', 'You have successfully verified your account.');
 }
Esempio n. 23
0
 /**
  * Gets the number of tickets for the given date range and status
  * 
  * @param array   $range  Date range to fetch stats for
  * @param unknown $status Status ID to look at
  * 
  * @return Type    Description
  */
 public static function graphDaily(array $range, $status)
 {
     // Get the user's groups
     $groups = Customer::where('id', auth()->user()->customer_id)->first()->groups()->get();
     $my_groups = [];
     foreach ($groups as $group) {
         $my_groups[] = $group->id;
     }
     $stats = [];
     $qry = "select created_at, count(*) as cnt " . "from tickets where group_id in (" . implode(', ', $my_groups) . ") and status_id = '" . $status . "' " . "and date_format(created_at, '%Y-%m-%d') between '" . $range[0] . "' and '" . $range[1] . "' " . "group by date_format(created_at, '%Y-%m-%d') " . "order by created_at";
     $tickets = DB::select($qry);
     foreach ($tickets as $ticket) {
         $stats[] = [$ticket->created_at, $ticket->cnt];
     }
     return $stats;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     try {
         $inputs = $request->all();
         unset($inputs['_token']);
         $device_tokens = Customer::where('platform', 'A')->lists('device_token');
         $is_sent = PnS::sendPnsToAndroidDevices($device_tokens, $inputs['body']);
         if ($is_sent) {
             $inputs['user_id'] = Auth::id();
             Notification::create($inputs);
         }
         return redirect()->to('/crm/notification/')->withMessage(Generate::success_message('Success', 'Sent Successfully'));
     } catch (Exception $e) {
         return redirect()->to('/crm/notification/')->withMessage(Generate::error_message('Failed', $e->getMessage()));
     }
 }
Esempio n. 25
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $page = \Request::get('page');
     $search = \Request::get('search');
     $getCategory = \Request::get('category');
     if (is_null($search) || is_null($getCategory) || $search == "" || $getCategory == "") {
         $customers = Customer::orderBy('id', 'DESC')->paginate(10);
     } else {
         $customers = Customer::where($getCategory, 'like', '%' . $search . '%')->orderBy($getCategory, 'DESC')->paginate(1000);
     }
     $category = array('' => 'kategori', 'name' => 'Nama', 'company_name' => 'Nama Perusahaan', 'address' => 'Alamat', 'email' => 'Email');
     if ($page == "transaction") {
         return view('transaction.customer', compact('customers', 'category'));
     } else {
         return view('customer.index', compact('customers', 'category'));
     }
 }
 /**
  * This function is to store the reservation details to db.
  * After storing the details this function redirects to the My Reservation view.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function hallReservation()
 {
     try {
         //set the timezone
         date_default_timezone_set("Asia/Colombo");
         $customer_email = Auth::user()->email;
         $customer_id = Customer::where('email', $customer_email)->value('cus_id');
         $customer_name = Customer::where('email', $customer_email)->value('name');
         $hall_name = HALL::where('hall_id', session('hall_selected'))->value('title');
         $event_date = session('event_date');
         //create instance of the HALL_RESERVATION model
         $hall_reservation = new HALL_RESERVATION();
         $hall_reservation->reserve_date = session('event_date');
         $hall_reservation->time_slot = session('timeSlot');
         $hall_reservation->total_amount = session('total_payable');
         $hall_reservation->cus_id = $customer_id;
         $hall_reservation->hall_id = session('hall_selected');
         $hall_reservation->status = 'PENDING';
         $hall_reservation->save();
         //retrieve the reservation id of the last saved reservation
         $res_id = $hall_reservation->hall_reservation_id;
         //delete the reservation details since already stored in the db
         Session::forget(['event_date', 'total_payable', 'hall_selected', 'CanPay']);
         //create an array in order to send the mail view with reservation details
         $data = array('res_id' => $res_id, 'hall_name' => $hall_name, 'event_date' => $event_date, 'name' => $customer_name);
         $job = new SendEmail($data, $customer_email, "initial_reservation_mail");
         $this->dispatch($job);
         //send a initial mail
         /*  Mail::send('emails.InitialRoomReservationMail', $data, function ($message)use($customer_email) {
                         $message->from(env('MAIL_FROM'), env('MAIL_NAME'));
         
                         $message->to($customer_email)->subject('Welcome to Amalya Reach!');
                     });*/
         //pusher
         $newNotification = new Notifications();
         $newNotification->notification = "New Reservation";
         $newNotification->body = "Room Reservation has been made";
         $newNotification->readStatus = '0';
         $newNotification->save();
         Pusher::trigger('notifications', 'Reservation', ['message' => 'New Hall Reservation has been made']);
         return redirect('myreserv')->with(['hreserv_status' => 'Reservation has been successfully made']);
     } catch (\Exception $e) {
         abort(500, $e->getMessage());
     }
 }
Esempio n. 27
0
 protected function checkUser($email, $password)
 {
     $customer = Customer::where('email', '=', $email)->get();
     if (count($customer) == 0) {
         return false;
     } else {
         foreach ($customer as $key => $value) {
             if (\Hash::check($password, $value['password'])) {
                 \Session::put('name', $value['name']);
                 \Session::put('email', $value['email']);
                 \Session::put('role', $value['role']);
                 return true;
             } else {
                 return false;
             }
         }
     }
 }
Esempio n. 28
0
 public function delete($id)
 {
     $user = User::find($id);
     $customer = Customer::where('user_id', '=', $user->id)->first();
     $customerId = $customer->id;
     // ищем наличие хотя бы одного проекта
     $customer_projects = Project::where('customer_id', '=', $customerId)->first();
     // если заказчик не активный и не используется ни в одном из проектов,
     // удаляем его
     if ($user->is_active == FALSE && $customer_projects == FALSE) {
         $customer->delete();
         $user->delete();
         return redirect('/customers')->withSuccess('Запись удалена');
     }
     // иначе помещаем в архив
     $user->is_archive = TRUE;
     $user->save();
     return redirect('/customers')->withSuccess('Запись в архиве');
 }
Esempio n. 29
0
 public function single($currentMonth)
 {
     $actualVisits = [];
     $MonthlyCustomerProducts = [];
     $doctors = Customer::where('mr_id', \Auth::user()->id)->get();
     foreach ($doctors as $singleDoctor) {
         $actualVisits[$singleDoctor->id] = Report::where('mr_id', \Auth::user()->id)->where('month', $currentMonth)->where('doctor_id', $singleDoctor->id)->count();
         $MonthlyCustomerProducts[$singleDoctor->id] = Customer::monthlyProductsBought([$singleDoctor->id])->toArray();
     }
     $products = Product::where('line_id', Employee::findOrFail(\Auth::user()->id)->line_id)->get();
     $coverageStats = Employee::coverageStats(\Auth::user()->id, $currentMonth);
     $allManagers = Employee::yourManagers(\Auth::user()->id);
     $totalProducts = Employee::monthlyDirectSales(\Auth::user()->id, $currentMonth);
     $totalSoldProductsSales = $totalProducts['totalSoldProductsSales'];
     $totalSoldProductsSalesPrice = $totalProducts['totalSoldProductsSalesPrice'];
     $dataView = ['doctors' => $doctors, 'MonthlyCustomerProducts' => $MonthlyCustomerProducts, 'actualVisits' => $actualVisits, 'products' => $products, 'totalVisitsCount' => $coverageStats['totalVisitsCount'], 'actualVisitsCount' => $coverageStats['actualVisitsCount'], 'totalMonthlyCoverage' => $coverageStats['totalMonthlyCoverage'], 'allManagers' => $allManagers, 'totalSoldProductsSales' => $totalSoldProductsSales, 'totalSoldProductsSalesPrice' => $totalSoldProductsSalesPrice];
     \Session::set('customers', $doctors);
     return view('mr.line.single', $dataView);
 }
 /**
  * This function store the room reservation details to db and clears the session
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function roomReservation(Request $request)
 {
     //set the timezone
     date_default_timezone_set("Asia/Colombo");
     //get the customer details currently logged in
     $customer_email = Auth::user()->email;
     $customer_id = Customer::where('email', $customer_email)->value('cus_id');
     $customer_name = Customer::where('email', $customer_email)->value('name');
     //convert the dates to date time insatance and get the difference
     $datetime1 = new DateTime(session('check_in'));
     $datetime2 = new DateTime(session('check_out'));
     $interval = $datetime1->diff($datetime2);
     //get the requested reservation details from the session
     $no_of_guests = session('adults') + session('kids');
     //formt the number of nights
     $no_of_nights = $interval->format('%d%') + config('constants.ADD_ONE_NIGHT');
     //call the saveReservationDetails function to save the reservation details to the database
     $res_id = $this->saveReservationDetails(session('check_in'), session('check_out'), $no_of_nights, $customer_id);
     //insert the the details to the RES_RMTYPE_CNT_RATE table
     foreach (session('room_types') as $room_type) {
         DB::table('RES_RMTYPE_CNT_RATE')->insert(['room_reservation_id' => $res_id, 'room_type_id' => $room_type, 'rate_code' => session('rate_code' . $room_type), 'count' => session('no_of_rooms' . $room_type)]);
     }
     //create an array with reservation details in ordr to send to the mail view
     $data = array('res_id' => $res_id, 'check_in' => session('check_in'), 'check_out' => session('check_out'), 'nights' => $no_of_nights, 'no_of_rooms' => session('rooms'), 'guests' => $no_of_guests, 'name' => $customer_name);
     //observer design pattern is used here, but this is design pattern is no use full
     /*$sub =  new ReservationRoom();
       $sub->attach(new ReservationTask());
       $sub->clearSession();*/
     //clear session
     $this->clearRoomSession("Full");
     //call the mailfunction send an email
     $this->sendInitialMail($data, $customer_email);
     //send an pusher notification to the admin
     //remove the magic values
     $newNotification = new Notifications();
     $newNotification->notification = "New Reservation";
     $newNotification->body = "Room Reservation has been made";
     $newNotification->readStatus = '0';
     $newNotification->save();
     Pusher::trigger('notifications', 'Reservation', ['message' => 'New Room Reservation has been made']);
     return redirect('myreserv')->with(['reserv_status' => 'Room_Reservation']);
 }