/**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function roulette()
 {
     if (ACL::checkUserPermission('bet.roulette') == false) {
         return Redirect::action('dashboard');
     }
     if (Auth::user()->isPlayer()) {
         $player_operator = Playeroperators::with('tabledetails')->where('player_id', Auth::user()->id)->get()->first();
         $gamedetails = Gamechannel::with('tabledetails.operator', 'tabledetails.gamedetails')->openchannel()->where('table_id', $player_operator->tabledetails->id)->take(1)->get()->first();
         $playerdetails = User::with('wallet')->where('id', Auth::user()->id)->get()->first();
         if (!empty($gamedetails)) {
             $title = Lang::get('Bet Roulette');
             $form_open = Form::open(array('method' => 'post', 'class' => 'smart-form', 'route' => array('bet.place')));
             $data = array('title' => $title, 'playerdetails' => $playerdetails, 'gamedetails' => $gamedetails, 'formOpen' => $form_open);
             return View::make('bet/roulette', $data);
         } else {
             return App::abort(404, 'Operator haven\'t start the roulette game.');
         }
     } else {
         return App::abort(404, 'Your account is not a player account.');
     }
 }
 public function start()
 {
     if (ACL::checkUserPermission('roulette.start') == false) {
         return Redirect::action('dashboard');
     }
     if (Auth::user()->isOperator()) {
         $game = Games::where('game_name', 'Roulette')->take(1)->get()->first();
         $table = Gametables::where('operator_id', $this->operator_id)->take(1)->get()->first();
         $players = Playeroperators::with('playerdetails', 'credits')->where('operator_id', $this->operator_id)->get();
         if (!empty($table)) {
             $create_channel = array('channel_id' => Utils::generateRandomString(), 'table_id' => $table->id);
             $channel_id = '';
             $channel = Gamechannel::openchannel()->where('table_id', $table->id)->take(1)->get()->first();
             if (!empty($channel)) {
                 $channel_id = $channel->id;
             } else {
                 $channel_create = Gamechannel::create($create_channel);
                 $channel_id = $channel_create->id;
             }
             $gamedetails = Gamechannel::with('tabledetails.gamedetails', 'tabledetails.operator', 'bets', 'bets.playerdetails')->find($channel_id);
             $totalbets = 0;
             $totalplayers = 0;
             if ($gamedetails->bets != null) {
                 foreach ($gamedetails->bets as $gamebets) {
                     $totalbets += $gamebets->bet_amount;
                     $totalplayers++;
                 }
             }
             $title = Lang::get('Start Game');
             $data = array('title' => $title, 'totalbets' => $totalbets, 'totalplayers' => $totalplayers, 'gamedetails' => $gamedetails, 'players' => $players);
             return View::make('operator/create', $data);
         } else {
             return App::abort(401, 'No Roulette table has been assigned to your account.');
         }
     } else {
         return App::abort(401, 'You are not a operator.');
     }
 }