Пример #1
0
 /**
  * @param Request $request
  *
  * @throws \Exception
  */
 public function generate(Request $request)
 {
     $this->validate($request, ['price' => 'required|integer', 'number' => 'required|integer']);
     $rows = $request->number;
     $price = $request->price;
     $data = [];
     $date = Carbon::today()->toFormattedDateString();
     for ($i = 1; $i <= $rows; $i++) {
         $code = $this->cashcode->generate();
         $data = array_add($data, $i, $code);
         $input = array_add($request->only('price'), 'code', $code);
         CashCode::create($input);
     }
     $data = CashCode::whereraw('price = ?', [$price])->get();
     Excel::create("CashCard Codes for {$price} == {$date}", function ($excel) use($data) {
         $excel->sheet('CashCard Codes One', function ($sheet) use($data) {
             $sheet->loadView('partials.code_table')->withCodes($data);
         })->download('csv');
     });
 }
Пример #2
0
 private function useCard($card_id)
 {
     CashCode::find($card_id)->delete();
 }
Пример #3
0
 /**
  * @return \Illuminate\View\View
  */
 public function check_result(Request $request)
 {
     $this->validate($request, ['code' => 'required', 'checkType' => 'required']);
     if ($request->checkType == 'ticket') {
         $code = $request->code;
         $code_type = "booking_ticket";
         $ticket = Booking::where('code', $code)->first();
         if ($ticket) {
             //				dd($ticket->user);
             return view('pages.check_result', ['code_type' => $code_type, 'ticket' => $ticket]);
         } else {
             //				dd($ticket);
             return view('pages.check_result', ['code_type' => $code_type, 'ticket' => $ticket])->withErrors('No Ticket Found');
         }
         dd('this is a ticket code');
     } else {
         $code_type = "cash_card";
         $code = $request->code;
         $cashCard = CashCode::where('code', $code)->first();
         if ($cashCard) {
             //				dd($code_type);
             return view('pages.check_result', ['code_type' => $code_type, 'card' => $cashCard]);
         } else {
             //				dd($cashCard);
             return view('pages.check_result', ['code_type' => $code_type, 'card' => $cashCard])->withErrors('No Card Found');
         }
     }
 }