/** * Run the database seeds. * * @return void */ public function run() { // $faker = \Faker\Factory::create(); foreach (range(1, 10) as $index) { $award = Award::find($index); $lottery = Lottery::create(['award_id' => $index, 'prob' => random_int(1, 100), 'number' => random_int(1, 100)]); } }
/** * Run the database seeds. * * @return void */ public function run() { // $infos = ['一等奖_耳机' => ['BEATS新版solo2头戴式耳机耳麦', 1, 100000], '二等奖_小米电源' => ['小米新款移动电源10000mAh 银色', 3, 10000], '二等奖_小米手环' => ['小米手环', 3, 10000], '二等奖_健康秤' => ['云康宝智能脂肪秤 蓝牙体脂仪', 3, 10000], '三等奖_自拍杆' => ['美逸线控自拍杆/自拍神器/迷你自拍器 太空蓝', 5, 5000], '三等奖_猪肉脯' => ['[百草味]靖江猪肉脯180g', 2, 3000], '三等奖_碧根果' => ['[百草味] 奶香碧根果218g', 2, 3000], '三等奖_巧克力' => ['amovo魔吻纯可可脂核桃伽纳彻', 1, 2000], '四等奖_焦糖咖啡' => ['雀巢(Nestle) 咖啡焦糖拿铁 100g', 1, 2000], '四等奖_辣条' => ['辣条', 1, 2000], '四等奖_麦吉士' => ['麦吉士图层酥塔', 1, 2000], '四等奖_摩卡咖啡' => ['Nestle雀巢咖啡摩卡咖啡条装105g', 4, 2000], '五等奖_旺仔牛奶苹果味' => ['旺旺 旺仔牛奶 苹果 (铁罐装) 245ml', 1, 2000], '五等奖_旺仔牛奶原味' => ['旺仔牛奶 原味(铁罐装) 245ml', 1, 2000], '五等奖_旺仔牛奶果汁味' => ['旺旺 旺仔牛奶 果汁味 (铁罐装) 245ml', 1, 2000], '五等奖_指甲刀' => ['简约时尚纯色折叠指甲钳', 1, 2000], '五等奖_包包' => ['可爱颜文字小钱包', 1, 2000], '五等奖_台历' => ['2016年田园风小清新年历计划本', 1, 2000], '五等奖_饭票' => ['儒林餐厅餐票', 4, 1000], '六等奖_便签本' => ['可爱喵星人N次贴', 6, 1000], '六等奖_裁纸刀' => ['迷你便携小号美工刀 快递开箱器', 5, 1000], '六等奖_彩色铅笔' => ['马可四色彩芯彩虹原木粗铅笔', 5, 1000], '六等奖_记事本' => ['简约纯色记事本', 5, 800], '六等奖_键盘刷' => ['长柄键盘清洁刷', 5, 800], '六等奖_搅拌勺' => ['不锈钢长柄搅拌勺', 5, 800], '六等奖_沐浴球' => ['糖果色海绵沐浴花 ', 5, 800], '六等奖_暖宝宝' => ['暖宝宝发热贴', 5, 800], '六等奖_贴纸' => ['可爱动物N次贴', 5, 800], '六等奖_文件袋' => ['可爱A4试卷文件袋', 5, 800], '六等奖_荧光笔' => ['彩色磨砂荧光笔记号', 5, 800], '六等奖_自动笔' => ['创意多功能复合笔:圆珠笔+自动铅笔一体笔', 5, 800]]; # award create foreach ($infos as $key => $award) { Award::create(['name' => $award[0], 'image_path' => 'imgs/goods/' . $key . '.jpg']); } #lottery foreach (range(1, 7) as $index) { $award = Award::find($index); $lottery = Lottery::create(['award_id' => $index, 'prob' => $index * 10, 'number' => 10]); } # goods create foreach ($infos as $key => $goods) { Goods::create(['name' => $goods[0], 'number' => $goods[1], 'points' => $goods[2], 'available' => true, 'image_path' => 'imgs/goods/' . $key . '.jpg']); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $this->validate($request, $this->rules); $input = Input::all(); if ($input['hh'] < 10) { $input['hh'] = "0" . $input['hh']; } if ($input['mm'] < 10) { $input['mm'] = "0" . $input['mm']; } $time = $input['hh'] . $input['mm']; $input['draw_time'] = $time; unset($input['hh']); unset($input['mm']); // dd($input); Lottery::create($input); return view('lotteries.manage')->with('message', 'Lottery data created'); }
public function add2lottery(Request $request) { $input = $request->all(); Lottery::create($input); Session::flash('flash_message', $input['name'] . '加入奖盘成功'); return \Redirect::back(); }