Ejemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //assume only card balance need to be stored
     $data = $request->all();
     $current_user = Auth::user();
     return Card::create(['user_id' => $current_user['id'], 'balance' => $data['balance']]);
 }
Ejemplo n.º 2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $card = Request::all();
     $user = Auth::user();
     $user_type = $user->user_type;
     if ($user_type == 'COMPANY') {
         // o bar está abrindo a comanda
         $id_company = $user->id_company;
         $phone = $card['phone'];
         // pega o celular do usuario
         $user = User::where('phone', '=', $phone)->get();
         // encontra o usuario vinculado a esse celular
         foreach ($user as $row) {
             $id_user = $row->id_user;
         }
     } else {
         // o usuário está abrindo a propria comanda
         $id_user = $user->id_user;
         $phone = $user->phone;
         $id_company = $card['id_company'];
         Session::set('id_company', $id_company);
     }
     // Gera o HASH da comanda
     $full_hash = md5($id_user . $phone . $id_company . microtime() . rand());
     $hash_len = strlen($full_hash);
     // HASH FINAL
     $hash_card = strtoupper(substr($full_hash, $hash_len - 6, 6));
     $new_card = ['id_user' => $id_user, 'id_company' => $id_company, 'table' => $card['table'], 'hash_card' => $hash_card];
     Card::create($new_card);
     return redirect('comandas?card=' . $hash_card);
 }
 public function run()
 {
     DB::table('cards')->delete();
     \App\Card::create(['id' => 1, 'front_text' => 'What is the best animal?', 'back_text' => 'Elephants. They\'re the best!', 'title' => 'card 1 title', 'category' => 'Animals']);
     \App\Card::create(['id' => 2, 'front_text' => 'What is the best pet?', 'back_text' => 'Ferrets. They\'re nature\'s slinky!', 'title' => 'Card 2 title', 'category' => 'Household Pets']);
     \App\Card::create(['id' => 3, 'front_text' => 'What is the most common animal pictured on the internet?', 'back_text' => 'CATS CATS CATS', 'title' => 'Card 3 title', 'category' => 'Internet Photos']);
     \App\Card::create(['id' => 4, 'front_text' => 'What common household animal makes a barking sound?', 'back_text' => 'Dogs! They also go "Woof!"', 'title' => 'Card 3 title', 'category' => 'Animal Sounds']);
     \App\Card::create(['id' => 5, 'front_text' => 'Which animal don\'t care?', 'back_text' => 'Honey badger don\'t care!', 'title' => 'Card 3 title', 'category' => 'Hilarious internet videos about animals']);
 }
 public function add(Request $request)
 {
     //return $cards = Card::paginate(2);
     if (Card::create($request->all())) {
         return back();
     } else {
         return 'No created';
     }
 }
Ejemplo n.º 5
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['card_name' => 'required|unique:cards', 'price' => 'required', 'admin_cost' => 'required', 'active_periode' => 'required']);
     if ($validator->fails()) {
         return redirect('card/create')->withErrors($validator)->withInput();
     }
     $input = $request->all();
     Card::create($input);
     Session::flash('message', 'Data successfully added');
     return redirect('card');
 }
Ejemplo n.º 6
0
 /**
  * заполнение таблицы кошельков
  */
 private function cardsTable()
 {
     Card::truncate();
     $data = [['user_id' => 1, 'title' => 'Visa', 'balance' => ''], ['user_id' => 2, 'title' => 'Master Card', 'balance' => ''], ['user_id' => 3, 'title' => 'Qiwi', 'balance' => '']];
     foreach ($data as $v) {
         Card::create($v);
     }
     // заполнение значений главной карты
     $users = User::all();
     foreach ($users as $u) {
         $u->main_card = Card::where('user_id', $u->id)->first()->id;
         $u->save();
     }
 }
Ejemplo n.º 7
0
 /**
  * Store a newly created resource in storage.
  * создаем кошелек
  *
  * POST /
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $input = $request->get('title');
     $input['user_id'] = $this->user->id;
     $names = ['title' => '"название кошелька"', 'user_id' => '"пользователь"'];
     $validator = \Validator::make($input, ['title' => 'required', 'user_id' => 'required'])->setAttributeNames($names);
     if ($validator->fails()) {
         return ['success' => false, 'content' => implode("\n", $validator->messages()->all())];
     }
     if (Card::create($input)) {
         return ['success' => true, 'content' => 'Кошелек успешно создан'];
     }
     return ['success' => false, 'content' => 'Не удалось создать кошелек'];
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     //
     $ldate = date('Y-m-d H:i:s');
     /*  
     $this->validate($request, [
         'saldo' => 'required'
     ]);
     */
     $card = new Card();
     $cardAttr = ['saldo' => $request->saldo, 'status' => '1', 'fecha_creacion' => $ldate];
     $card = Card::create($cardAttr);
     if ($card->save()) {
         return Response::json(array('success' => true, "id" => $card->Id_tarjeta), 200);
     } else {
         return Response::json(array('success' => false), 200);
     }
 }
 public function store()
 {
     Card::create(Request::all());
     return redirect('cards');
 }