Example #1
0
 public function newloot(Request $request)
 {
     //  if(\DB::table('lootgames')->where('name', "Тест")->where('status',0)->count() == 0){
     //$returnValue = '[{"inventoryId":"0","classid":"7","name":"Тест","market_hash_name":"Test","rarity":"Тайное","quality":"Прямо с fastloot )","type":"Прямо с fastloot )"}]';
     //  $this->redis->rpush(self::NEW_ITEMS_CHANNEL, $returnValue);}
     $jsonItems = $this->redis->lrange(self::NEW_ITEMS_CHANNEL, 0, -1);
     foreach ($jsonItems as $jsonItem) {
         $items = json_decode($jsonItem, true);
         foreach ($items as $item) {
             $dbItemInfo = Item::where('market_hash_name', $item['market_hash_name'])->first();
             /*	if($item['classid'] == 7){
             	 
             
                                 $item['steam_price'] =0;
                                 $item['price'] = 0;
             					$item['maxuser'] = 10; 
             	Loot::create($item);
              }
                             else */
             if (is_null($dbItemInfo)) {
                 $itemInfo = new SteamItem($item);
                 $max = rand(100, 200);
                 $item['steam_price'] = $itemInfo->price;
                 $item['price'] = round($item['steam_price'] / $max + rand(1, 10));
                 $item['maxuser'] = $max;
                 Loot::create($item);
             } else {
                 $max = rand(100, 200);
                 $item['steam_price'] = $dbItemInfo->price;
                 $item['price'] = round($item['steam_price'] / $max + rand(1, 10));
                 $item['maxuser'] = $max;
                 Loot::create($item);
             }
         }
         $this->redis->lrem(self::NEW_ITEMS_CHANNEL, 1, $jsonItem);
     }
     return response()->json(['success' => true]);
 }
Example #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @todo create custom Request
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     Loot::create($request->all());
     return redirect('loot');
 }