/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // $lottery = Lottery::findOrFail($id); $lottery->delete(); \Session::flash('flash_message', "奖品" . $lottery->Award->name . "从奖盘删除成功"); return \Redirect::back(); }
/** * 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)]); } }
public function index_winning() { $lotteries = Lottery::all(); $series = Series::all(); $_results = Result::where(array('date' => date('Y-m-d')))->get(); $results_multi = array(); foreach ($_results as $result) { if (empty($results_multi["{$result->lottery_id}"])) { $results_multi["{$result->lottery_id}"] = array(); } $results_multi["{$result->lottery_id}"]["{$result->series_id}"] = $result->winning_number; } $is_admin = true; return view('lotteries.winning', compact('lotteries', 'series', 'results_multi', 'is_admin')); }
/** * 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'); }
/** * Show the application dashboard to the user. * * @return Response */ public function index() { $series = Series::all(); // get lottery to display $time = date("Hi"); $next_draw_lottery = Lottery::where("draw_time", '>', $time)->orderBy("draw_time")->first(); if ($next_draw_lottery) { $next_draw_time = date_create_from_format("Hi", $next_draw_lottery->draw_time); $next_draw_time = $next_draw_time->format("h:i A"); } else { $next_draw_time = "--:--"; } $lottery = Lottery::where("draw_time", '<=', $time)->orderBy("draw_time", "desc")->first(); if ($lottery) { $date = date('Y-m-d'); $results = Result::where(array("date" => $date, 'lottery_id' => $lottery->id))->with('series')->get(); } // dd($results->first()->series->code); return view('home', compact('results', 'lottery', 'series', 'next_draw_time')); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // /** * * php + ajax 幸运大转盘 * @author Sim <*****@*****.**> * @time 2014年9月25日15:37:32 * @url http://www.yiifcms.com/post/59/ * */ $result['message'] = '0'; $user = Auth::user(); $points = $user->points; if ($points < 100) { $result['message'] = '1'; } else { // //奖项初始化 $a = Lottery::all(); foreach ($a as $aaa) { if ($aaa->number == 0) { $aaa->prob = 0; $aaa->save(); } } $prize_arr = array('0' => array('id' => $a[0]->award_id, 'min' => 1, 'max' => 29, 'prize' => '一等奖', 'v' => $a[0]->prob, 'number' => $a[0]->number), '1' => array('id' => $a[1]->award_id, 'min' => 302, 'max' => 328, 'prize' => '二等奖', 'v' => $a[1]->prob, 'number' => $a[1]->number), '2' => array('id' => $a[2]->award_id, 'min' => 242, 'max' => 268, 'prize' => '三等奖', 'v' => $a[2]->prob, 'number' => $a[2]->number), '3' => array('id' => $a[3]->award_id, 'min' => 182, 'max' => 208, 'prize' => '四等奖', 'v' => $a[3]->prob, 'number' => $a[3]->number), '4' => array('id' => $a[4]->award_id, 'min' => 122, 'max' => 148, 'prize' => '五等奖', 'v' => $a[4]->prob, 'number' => $a[4]->number), '5' => array('id' => $a[5]->award_id, 'min' => 62, 'max' => 88, 'prize' => '六等奖', 'v' => $a[5]->prob, 'number' => $a[5]->number), '6' => array('id' => $a[6]->award_id, 'min' => array(32, 92, 152, 212, 272, 332), 'max' => array(58, 118, 178, 238, 298, 358), 'prize' => '七等奖', 'v' => $a[6]->prob, 'number' => $a[6]->number)); foreach ($prize_arr as $key => $val) { $arr[$val['id']] = $val['v']; } $rid = $this->getRand($arr); //根据概率获取奖项id $res = $prize_arr[$rid - 1]; //中奖项 $min = $res['min']; $max = $res['max']; if ($res['id'] == 7) { //七等奖 $i = mt_rand(0, 5); $result['angle'] = mt_rand($min[$i], $max[$i]); } else { $result['angle'] = mt_rand($min, $max); //随机生成一个角度 } $result['prize'] = $res['prize']; $award_id = $res['id']; $award = Lottery::findorFail($award_id); $award->number = $award->number - 1; $award->save(); \App\AwardUser::create(['user_id' => $user->id, 'award_id' => $award_id, 'is_gotten' => '0', 'created_at' => Carbon::now()]); // 这里如果采用先记录中奖信息,后台管理员兑奖时再从awards表中对number减1也可。 $user->points = $user->points - 100; $user->save(); } //$user->save(); //print $points; //echo $user_id; echo json_encode($result); }
/** * ให้ค่า instance ของ model ที่ระบุด้วย entity type และ $refId * @param int $type * @param int $refId * @return ActiveRecord */ public static function getInstance($type, $refId, $orderNo = NULL) { $instance = null; switch ($type) { case self::TYPE_ACTIVITY: $instance = Activity::findOne($refId); break; case self::TYPE_BLOG: $instance = Blogs::findOne($refId); break; case self::TYPE_CARTOON: $arr = preg_split('/-/', $refId); $instance = CartoonChapter::findOne(array('cartoonId' => $arr[0], 'chapter' => $arr[1])); break; case self::TYPE_CONTENT: $instance = Content::findOne($refId); break; case self::TYPE_DOCUMENT: $instance = Document::findOne(array('type' => $type, 'refId' => $refId, 'itemNo' => $orderNo)); break; case self::TYPE_FAQ: $instance = Faq::findOne($refId); break; case self::TYPE_FEEDCONTENT: $instance = FeedContent::findOne($refId); break; case self::TYPE_FEED: $instance = Feed::findOne($refId); break; case self::TYPE_GALLERY: $instance = Gallery::findOne($refId); break; case self::TYPE_INFOGRAPHIC: $instance = InfoGraphic::findOne($refId); break; case self::TYPE_LIVEREPORT: $instance = LiveReport::findOne($refId); break; case self::TYPE_LOTTERY: $instance = Lottery::findOne($refId); break; case self::TYPE_BUNNY: case self::TYPE_MEDIA_COLLECTION: $instance = MediaCollection::findOne($refId); break; case self::TYPE_NEWSPAPER: // temporary class for media upload $instance = new stdClass(); $instance->createTime = date('Y-m-d H:i:s'); break; case self::TYPE_NOVEL: $instance = Novel::findOne($refId); break; case self::TYPE_PERSON: $instance = Person::findOne($refId); break; case self::TYPE_SPORT_PLAYER: $instance = Player::findOne($refId); break; case self::TYPE_SPORT_TEAM: $instance = Team::findOne($refId); break; case self::TYPE_QUOTE: $instance = Quote::findOne($refId); break; case self::TYPE_WIDGET: $instance = Widget::findOne($refId); break; case self::TYPE_TV_ANCHOR: $instance = TvAnchor::findOne($refId); break; case self::TYPE_TV_PROGRAM: $instance = TvProgram::findOne($refId); break; case self::TYPE_TV_HIGHLIGHT: $instance = TvHighlight::findOne($refId); break; case self::TYPE_TV_SCHEDULE: $instance = TvSchedule::findOne($refId); break; case self::TYPE_USER: $instance = User::findOne($refId); break; case self::TYPE_VIDEO: $instance = Video::findOne($refId); break; case self::TYPE_VIDEO_PLAYLIST: $instance = VideoPlaylist::findOne($refId); break; case self::TYPE_WATCHTOPIC: $instance = WatchTopic::findOne($refId); break; case self::TYPE_WEATHER: $instance = WeatherForecast::findOne($refId); break; } return $instance; }
public function bowlers() { $baseURL = '../public/'; $allBowlers = User::getAllBolwerDetails(); if (empty($allBowlers)) { $allBowlers = 0; } foreach ($allBowlers as $bowler) { $Bowlers[$bowler->id][] = ['data' => $bowler]; } $userDetails = Auth::user(); $jackpotCount = Lottery::getJackpotCountOfUser($userDetails->id); $totalTickets = Lottery::getTotalLotteryCount($userDetails->id); $totalJackpot = Lottery::getTotaljackpotAmountofUser($userDetails->id); $totalLeagues = League::getLeagueByBowler($userDetails->id); return \View::make('bowlers')->with('Bowlers', $Bowlers)->with('userDetails', $userDetails)->with('jackpotCount', $jackpotCount)->with('totalTickets', $totalTickets)->with('totalJackpot', $totalJackpot)->with('totalLeagues', $totalLeagues)->with('baseURL', $baseURL); }
public function isInLottery() { return \App\Lottery::where('award_id', $this->id)->count() >= 1; }
public function recordResultforRoll($leagueId, $lotteryId) { $isValidToken = User::checkAuth(); $postedData = file_get_contents("php://input"); $postedData = substr($postedData, 2, -2); $pinCount = explode(':', $postedData)[1]; $jackpotAmount = Lottery::getCurrentJackpot($lotteryId); if ($isValidToken != 0) { $bowlerId = $isValidToken[0]->id; if ($pinCount == 10) { $winnerAmount = $jackpotAmount[0]->balence; $jackpot = Lottery::getstrike($lotteryId, $bowlerId, $winnerAmount); return \Response::json($jackpot, 200); } else { $winnerAmount = $jackpotAmount[0]->balence / 10; $jackpot = Lottery::getnonstrike($lotteryId, $bowlerId, $winnerAmount, $pinCount[0]); return \Response::json($jackpot, 200); } } else { return json_encode("Please enter valid Authentication Token"); } }
public function add2lottery(Request $request) { $input = $request->all(); Lottery::create($input); Session::flash('flash_message', $input['name'] . '加入奖盘成功'); return \Redirect::back(); }