/** * Run the database seeds. * * @return void */ public function run() { $faker = Faker\Factory::create(); // Shop::truncate(); $startDate = Carbon::createFromTimeStamp($faker->dateTimeBetween('-1 years', '+1 month')->getTimestamp()); foreach (range(1, 20) as $index) { Shop::create(['name' => $faker->name, 'shopDescription' => $faker->realText($maxNbChars = 200, $indexSize = 2), 'location' => $faker->city, 'contactNumber' => $faker->phoneNumber, 'openingDate' => $startDate->toDateTimeString(), 'email' => $faker->companyEmail]); } }
/** * Run the migrations. * * @return void */ public function up() { Schema::create('shops', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('floor'); $table->boolean('lot_no'); $table->timestamps(); }); Shop::create(['name' => 'Midvelly', 'floor' => '10', 'lot_no' => '10-8']); Shop::create(['name' => 'KLCC', 'floor' => '11', 'lot_no' => '12-1']); Shop::create(['name' => 'Quill', 'floor' => '12', 'lot_no' => '9-2']); }
public function addItemsToSale() { $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 (is_null($dbItemInfo)) { $itemInfo = new SteamItem($item); $item['steam_price'] = $itemInfo->price; $item['price'] = round($item['steam_price'] / 100 * self::PRICE_PERCENT_TO_SALE); Shop::create($item); } else { $item['steam_price'] = $dbItemInfo->price; $item['price'] = round($item['steam_price'] / 100 * self::PRICE_PERCENT_TO_SALE); Shop::create($item); } } $this->redis->lrem(self::NEW_ITEMS_CHANNEL, 1, $jsonItem); } return response()->json(['success' => true]); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $shop = Shop::create($request->all()); return \Response::json($shop); }