/**
  * Handle Job.
  */
 public function handle()
 {
     $notification = new Notification();
     $notification->balance_id = $this->balance->id;
     $this->card->notifications()->save($notification);
     $this->sendNotificationPush($notification, $this->card, $this->balance);
 }
Exemplo n.º 2
0
 public function store(Request $request, Card $card)
 {
     $note = new Note();
     $note->body = $request->body;
     $card->notes()->save($note);
     return back();
 }
Exemplo n.º 3
0
 public function store(Request $request, Card $card)
 {
     //return $request->all();
     //return \Request::all();
     //return request()->all();
     //return $card;
     //        $note = new Note();
     //        $note->body = $request->body;
     //        $card->notes()->save($note);
     //        $note = new Note(['body'=> $request->body]);
     //        $card->notes()->save($note);
     //$note = new Note(['body'=> $request->body]);
     //        $card->notes()->save(
     //            new Note(['body'=> $request->body])
     //        );
     //        $card->notes()->create([
     //            'body'=>$request->body
     //        ]);
     //        $card->notes()->create($request->all());
     $this->validate($request, ['body' => 'required|min:10']);
     $note = new Note($request->all());
     // $note->user_id = Auth::id();
     // $note->by(Auth::user());
     //$note->user_id = 1;
     $card->addNote($note, 1);
     return back();
 }
 public function store(Request $request, Card $card)
 {
     $this->validate($request, ['body' => 'required']);
     $note = new Note($request->all());
     $card->addNote($note, 1);
     return back();
 }
 public function store(Request $request, Card $card)
 {
     // Option 1
     /*
         	$note = new Note;
         	$note->body = $request->body;
         	$card->notes()->save($note);
     */
     //Option 2
     /*
     $note = new Note(['body' => $request->body]);
     $card->notes()->save($note);
     */
     //Option 3
     /*
     $card->notes()->create([
     	'body' =>$request->body
     	]);
     */
     //Option 4
     /*
     $card->notes()->create($request->all());
     */
     //Option 5 el mejor
     $card->addNote(new Note($request->all()));
     return back();
 }
Exemplo n.º 6
0
 public function store(Request $request, Card $card)
 {
     $this->validate($request, ['body' => 'required|min:10']);
     $note = new Note();
     $note->user_id = 1;
     $note->body = $request->body;
     $card->notes()->save($note);
     return back();
 }
Exemplo n.º 7
0
 public function store(Request $request, Card $card)
 {
     $this->validate($request, ['body' => 'required|min:10|max:140']);
     $note = new Note($request->all());
     //$note->user_id = 1;
     //$note->body = $request->body;
     //$card->notes()->save($note);
     //$note->by(Auth::user());
     $card->addNote($note, 1);
     return back();
 }
Exemplo n.º 8
0
 public function show(Card $card)
 {
     //        // using eager loading
     //        $card = Card::with('notes')->get();
     // eager loading 2
     $card->load('notes.user');
     //return $card;
     // using eager loading
     //$card = Card::with('notes.user')->find(1);
     //return $card;
     //        $card = Card::find($id);
     return view('cards.show', compact('card'));
     //return $card;
 }
 /**
  * Handle Job.
  *
  * @param Client $client
  */
 public function handle(Client $client)
 {
     try {
         $response = $client->get('http://mpeso.saldotuc.com/cards/' . $this->card->number . '/balance');
         $responseParsed = json_decode($response->getBody(), true);
         $this->handleBalance($this->card, $responseParsed['balance']);
     } catch (ClientException $e) {
         if (Response::HTTP_NOT_FOUND == $e->getCode()) {
             $this->card->delete();
         }
     } catch (\Exception $e) {
         Log::info(sprintf('Attempting to queue "request balance" for card %s after exception. Delayed execution for 2 seconds after (%d) attempts. Message: [%s] Exception class: [%s]', $this->card->number, $this->attempts(), $e->getMessage(), get_class($e)));
         $this->release(2);
     }
 }
Exemplo n.º 10
0
 public function paid()
 {
     // Gacha Id TODO
     // Stone Check
     // TODO 消耗石头常量化
     if ($this->_playerData->stone < 5) {
         // 石头不够的情况
         return Response::json(['error' => 'not enough stone']);
     }
     // 抽奖列表列表 TODO APC缓存
     $lstGachaItems = GachaItems::all()->toArray();
     // 抽选
     $objGachaItem = $this->_drawing($lstGachaItems);
     if ($objGachaItem) {
         $card = Card::find($objGachaItem['card_id']);
         // 抽到卡片的品质
         $quality = $objGachaItem['quality'];
         $ownedCard = $this->_player->appendCard($objGachaItem['card_id'], $quality);
         if ($ownedCard) {
             $this->_playerData->stone = $this->_playerData->stone - $this->PAID_NEED_STONE;
             if ($this->_playerData->save()) {
                 return Response::json($ownedCard);
             }
         }
     }
     return Response::json(['error' => 'Create Card Failure']);
 }
Exemplo n.º 11
0
 /**
  * @return \Illuminate\View\View
  */
 public function destroy()
 {
     $idArray = $_REQUEST["ids"];
     Card::destroy($idArray);
     $cardpack = Cardpack::findOrFail($_REQUEST["cardpackid"]);
     return view('cards._table', compact('cardpack'));
 }
Exemplo n.º 12
0
 /**
  * 赋予玩家一张卡片
  * @param $intCardId
  * @param string $strQuality
  * @return \App\OwnedCard|bool
  */
 public function appendCard($intCardId, $strQuality = 'normal')
 {
     // 取得卡片情报
     $objCard = Card::find($intCardId);
     // 卡片情报不正确
     if (!$objCard || empty($objCard)) {
         return false;
     }
     // Transaction
     DB::beginTransaction();
     try {
         // 初始化玩家卡片
         $objOwnedCard = new OwnedCard();
         // 玩家卡片情报Set
         $objOwnedCard->createOwnedCard($intCardId, $this->id, $strQuality);
         // 保存
         if (!$objOwnedCard->save()) {
             throw new Exception('Save Failed');
         }
         DB::commit();
     } catch (Exception $e) {
         // TODO Dev Log
         DB::rollback();
         // 失败
         return false;
     }
     return $objOwnedCard;
 }
Exemplo n.º 13
0
 /**
  * 玩家卡片取得处理
  */
 public function cardBox()
 {
     // 玩家ID获取
     $intPlayerId = Input::get('player_id');
     // 玩家所持卡片全取得
     $lstCard = OwnedCard::where('player_id', $intPlayerId)->get();
     return view('admin.player.card-box')->withCards(Card::all())->withAttrs(Attr::all())->withRaces(Race::all())->withJobs(Job::all())->withSkills(Skill::all())->withOwnedCards($lstCard);
 }
Exemplo n.º 14
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $card = Card::findOrFail($id);
     //Check if card belongs to current user
     if ($card->cardpack->user->id == Auth::id()) {
         $card->delete();
     }
 }
 public function add(Request $request)
 {
     //return $cards = Card::paginate(2);
     if (Card::create($request->all())) {
         return back();
     } else {
         return 'No created';
     }
 }
 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']);
 }
Exemplo n.º 17
0
 /**
  * Store a newly created resource in storage.
  *
  * @param Request $request
  * @param $cardNumber
  *
  * @return Response
  */
 public function store(Request $request, $cardNumber)
 {
     $this->validate($request, ['balance' => 'required|numeric|min:0']);
     $balance = $request->input('balance');
     $card = Card::firstOrCreate(['number' => $cardNumber]);
     $currentBalance = $card->addBalance($balance);
     if ($currentBalance->wasRecentlyCreated) {
         return $this->respondCreated(fractal()->item($currentBalance, new BalanceTransformer())->toArray());
     }
     return $this->respond(fractal()->item($currentBalance, new BalanceTransformer())->toArray());
 }
 /**
  * Check if access is allowed given an RFID card identifier.
  *
  * @param   Resource  $resource
  * @param   string    $cardId
  * @return  Response
  */
 public function check(Resource $resource, $cardId)
 {
     $now = Date::now();
     try {
         $card = Card::findOrFail($cardId);
         // @todo: refactor for single responsibility
         $reservation = $resource->reservations()->where('starts_at', '<=', $now)->where('ends_at', '>', $now)->where('user_id', '=', $card->user->id)->first();
         $allow = $reservation ? true : false;
         //
     } catch (ModelNotFoundException $e) {
         $reservation = null;
         $allow = false;
     }
     return ['time' => $now->format('Y-m-d H:i:s'), 'reservation' => $reservation, 'allow' => $allow];
 }
Exemplo n.º 19
0
 /**
  * заполнение таблицы пранзакций
  */
 private function transactionsTable()
 {
     Transaction::truncate();
     $u = User::count();
     $c = Card::count();
     $i = 0;
     while ($i < 10) {
         ++$i;
         Transaction::create(['user_id' => rand(1, $u), 'card_id' => rand(1, $c), 'money' => rand(0, 1000)]);
     }
     $crd = Card::all();
     foreach ($crd as $v) {
         $v->balance = Transaction::where('card_id', $v->id)->sum('money');
         $v->save();
     }
 }
 public function run()
 {
     DB::table('card_playlist')->delete();
     $playlist = \App\Playlist::find(1);
     $playlist->cards()->attach(\App\Card::find(1));
     $playlist->cards()->attach(\App\Card::find(2));
     $playlist->cards()->attach(\App\Card::find(3));
     $playlist->cards()->attach(\App\Card::find(4));
     $playlist->cards()->attach(\App\Card::find(5));
     $playlist = \App\Playlist::find(2);
     $playlist->cards()->attach(\App\Card::find(2));
     $playlist->cards()->attach(\App\Card::find(3));
     $playlist->cards()->attach(\App\Card::find(5));
     $playlist = \App\Playlist::find(3);
     $playlist->cards()->attach(\App\Card::find(1));
     $playlist->cards()->attach(\App\Card::find(2));
     $playlist->cards()->attach(\App\Card::find(4));
 }
Exemplo n.º 21
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $quantities = Request::get('quantity');
     $products = Request::get('id_product');
     $hash_card = Request::get('hash_card');
     $user = Auth::user();
     $user_type = $user->user_type;
     if ($user_type == 'COMPANY') {
         // o bar fez o pedido
         $user_card = Card::where('hash_card', '=', $hash_card)->get();
         foreach ($user_card as $row) {
             $id_user = $row['id_user'];
         }
         $id_company = $user->id_company;
     } else {
         // o usuário fez o pedido
         $id_user = $user->id_user;
         $id_company = Session::get('id_company');
     }
     $total_products = count($products);
     for ($i = 0; $i < $total_products; $i++) {
         // faz um loop em todos os produtos e cria uma matriz com produto e quantidade
         if ($quantities[$i] > 0) {
             // se o produto tem quantidade maior do que zero, insere na matriz
             $id_product = $products[$i];
             $quantity = $quantities[$i];
             $product = Product::find($id_product);
             // localiza o produto inserido
             $product_price = $product->price;
             // localiza o preço do produto em questão
             $order_data[] = ['id_user' => $id_user, 'id_company' => $id_company, 'id_product' => $id_product, 'quantity' => $quantity, 'product_price' => $product_price, 'hash_card' => $hash_card];
         }
     }
     Order::insert($order_data);
     // cria a ordem
     return redirect('pedidos?add&card=' . $hash_card);
 }
Exemplo n.º 22
0
 /**
  * 取得全部卡片的JSON
  *
  * @return Response JSON
  */
 public function cards()
 {
     $cards = Card::all();
     return Response::json($cards);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     //
     $card = Card::find($id);
     try {
         $statusCode = 200;
         if ($request->has('saldo')) {
             $card->saldo = $request->saldo;
         }
         if ($request->has('status')) {
             $card->status = $request->status;
         }
         if ($card->save()) {
             $response = ["success" => true];
         } else {
             $response = ["success" => false];
         }
     } catch (Exception $e) {
         $response = ["error" => "Error interno"];
         $statusCode = 500;
     } finally {
         return Response::json($response, $statusCode);
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     Card::all()->each(function ($card) {
         $this->dispatch(new RequestBalanceForCard($card));
     });
 }
Exemplo n.º 25
0
 /**
  * Get all of the cards for a given user
  *
  * @param User $user
  * @return Collection
  */
 public function forUser(User $user)
 {
     return Card::where('user_id', $user->id)->orderBy('created_at', 'asc')->get();
 }
 public function ajax_card(Request $request)
 {
     if (Request::ajax()) {
         $card_id = $request->all();
         $data = Card::where('id', $card_id)->first();
         dd($data);
     }
 }
Exemplo n.º 27
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $card = Card::findOrFail($id);
     $this->validate($request, ['title' => 'required|max:255', 'url' => 'required|url', 'desc' => 'max:255']);
     $tags = $request->tags;
     if ($tags) {
         foreach ($tags as $tag) {
             if (is_numeric($tag)) {
                 $tagArr[] = $tag;
             } else {
                 $newTag = Tag::create(['name' => $tag]);
                 $tagArr[] = $newTag->id;
             }
         }
     }
     $client = new Client();
     $httpReq = $client->get($request->url);
     $res = $httpReq->getBody();
     $crawler = new Crawler($res->getContents());
     $og_img_tag = $crawler->filter('meta[property="og:image"]');
     $og_img = $og_img_tag->attr('content');
     $card->fill(['title' => $request->title, 'url' => $request->url, 'desc' => $request->desc, 'og_image' => $og_img])->save();
     $card->tags()->sync($tagArr);
     return redirect('/cards');
 }
 public function store()
 {
     Card::create(Request::all());
     return redirect('cards');
 }
 public function index()
 {
     $cards = Card::all();
     return view('cards.index', compact('cards'));
 }
Exemplo n.º 30
0
 /**
  * Display the specified resource.
  *
  * @param int     $number
  * @param Request $request
  *
  * @return Response
  */
 public function show($number, Request $request)
 {
     $card = Card::where('number', $number)->firstOrFail();
     return $this->respond(fractal()->item($card, new CardTransformer())->parseIncludes($request->input('include', []))->toArray());
 }