当前位置: 首页>>代码示例>>PHP>>正文


PHP Game::find方法代码示例

本文整理汇总了PHP中Game::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Game::find方法的具体用法?PHP Game::find怎么用?PHP Game::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Game的用法示例。


在下文中一共展示了Game::find方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 /**
  * Enregistre un nouveau paris
  *
  * @return Response
  */
 public function store()
 {
     $user = User::getUserWithToken($_GET['token']);
     $input = Input::all();
     $input['user_id'] = $user->id;
     $validator = Validator::make($input, Bet::$rules, BaseController::$messages);
     if ($validator->fails()) {
         return Response::json(array('success' => false, 'payload' => array(), 'error' => $this->errorsArraytoString($validator->messages())), 400);
     }
     //On vérifie si la date du match n'est pas dépassé
     if (new DateTime() > new DateTime(Game::find($input['game_id'])->date)) {
         return Response::json(array('success' => false, 'payload' => array(), 'error' => "Le date du match est dépassé !"), 400);
     }
     $bet = Bet::whereRaw('user_id = ? && game_id = ?', array($input['user_id'], $input['game_id']))->first();
     //Si un paris sur le même match pour cet utilisateur existe, erreur envoyée.
     if ($bet) {
         return Response::json(array('success' => false, 'payload' => array(), 'error' => "Un paris existe déjà sur ce match !"), 400);
     }
     //On vérifie si la somme misé est disponible
     if ($input['points'] > $user->points) {
         return Response::json(array('success' => false, 'payload' => array(), 'error' => "Vous avez miser plus de points que vous en avez !"), 400);
     }
     $game = Game::find($input['game_id']);
     //On vérifie si le winner est bien une équipe du match
     if ($input['winner_id'] != $game->team1_id && $input['winner_id'] != $game->team2_id) {
         return Response::json(array('success' => false, 'payload' => array(), 'error' => "Veuillez mettre une équipe du match !"), 400);
     }
     $bet = Bet::create($input);
     Transaction::addTransaction($input['user_id'], $bet->id, $input['points'], 'bet');
     return Response::json(array('success' => true, 'payload' => $bet->toArray(), 'message' => 'Pari enregistré (' . $bet->points . ' points) sur : ' . $game->team1->name . ' (' . $bet->team1_goals . ') - (' . $bet->team2_goals . ') ' . $game->team2->name));
 }
开发者ID:Cclleemm,项目名称:worldcup,代码行数:36,代码来源:BetController.php

示例2: testGetViewWithoutProductsOnSale

 public function testGetViewWithoutProductsOnSale()
 {
     $game = Game::find(2);
     $slug = $game->slug;
     $name = $game->title;
     $response = $this->call('GET', "/game/{$slug}");
     $this->assertContains($game->title, $response->getContent());
     $this->assertContains("Sell my used {$name}", $response->getContent());
     $this->assertContains('Used games for sale (0)', $response->getContent());
 }
开发者ID:adriacidre,项目名称:gamereuse,代码行数:10,代码来源:GameControllerTest.php

示例3: checkUpdates

 public function checkUpdates()
 {
     $jsonList = array();
     App::uses('Game', 'Model');
     $GameModel = new Game();
     App::uses('RaidheadSource', 'Model/Datasource');
     $RaidHead = new RaidheadSource();
     $apiGames = $RaidHead->gets();
     $params = array();
     $params['recursive'] = -1;
     $params['fields'] = array('import_slug', 'import_modified');
     $params['conditions']['import_slug !='] = null;
     if ($games = $GameModel->find('all', $params)) {
         foreach ($games as $game) {
             if (!empty($apiGames[$game['Game']['import_slug']])) {
                 if ($apiGames[$game['Game']['import_slug']]['lastupdate'] > $game['Game']['import_modified']) {
                     $jsonList[] = $game['Game']['import_slug'];
                 }
             }
         }
     }
     return json_encode($jsonList);
 }
开发者ID:Chaoslan,项目名称:mushraider,代码行数:23,代码来源:AjaxController.php

示例4: array

  		<?php 
            }
            ?>
  	<?php 
        }
        ?>
	<?php 
    }
} else {
    ?>
  <?php 
    //Populate array for view tournament table
    $allTournaments = Tournament::find('all', array('conditions' => array('eventID = ?', $_SESSION['event'])));
    ?>
  <?php 
    $allGames = Game::find('all');
    ?>
  <h2>Tournament Management</h2>
  <form action="/includes/modules/tournamentManagement/tournaments.php" class="form-horizontal" method="POST">
    <div class="form-group" id="tournamentNameInputDiv">
      <label for="tournamentName" class="col-sm-2 control-label">Name</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" id="tournamentName" name="tournamentName" placeholder="Tournament name" value="<?php 
    echo $_POST['tournamentName'];
    ?>
" required>
      </div>
    </div>
    <div class="form-group" id="gameInputDiv">
      <label for="game" class="col-sm-2 control-label">Game</label>
      <div class="col-sm-10">
开发者ID:richardmountain,项目名称:lanopsManager,代码行数:31,代码来源:tournaments.php

示例5: destroy_no_redirect

 public static function destroy_no_redirect($gameid)
 {
     // Destroy both the game and its scores.
     $game = Game::find($gameid);
     $player_scores = $game->scores;
     foreach ($player_scores as $playername => $scores) {
         foreach ($scores as $score) {
             $score->destroy();
         }
     }
     $game->destroy();
 }
开发者ID:rryanburton,项目名称:Tsoha-Bootstrap,代码行数:12,代码来源:game_controller.php

示例6: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update()
 {
     // Fetch all request data.
     $data = Input::only('timezone', 'games');
     // Build the validation constraint set.
     $rules = array('timezone' => array('regex:([0-9a-zA-Z /+-]+)'));
     // Create a new validator instance.
     $validator = Validator::make($data, $rules);
     if ($validator->passes()) {
         try {
             // Find the user using the user id
             $user = User::find(Sentry::getuser()->id);
             // Update the user details
             $user->timezone = Input::get('timezone');
             $user_games = $user->userGame()->get();
             $games = Input::get('games');
             foreach ($user_games as $user_game) {
                 if ($games && !in_array($user_game->id, $games)) {
                     $user->userGame($user_game)->detach();
                 } elseif ($games == false) {
                     $user->userGame($user_game)->detach();
                 }
             }
             if ($games) {
                 foreach ($games as $game) {
                     $game_attach = Game::find($game);
                     if (!$user->userGame()->where('game_id', '=', $game_attach->id)->first()) {
                         $user->userGame()->attach($game_attach);
                     }
                 }
             }
             // Update the user
             if ($user->save()) {
                 return Redirect::to('/user/edit')->with('global_success', 'Profile has been updated.');
             } else {
                 return Redirect::to('/user/edit')->with('global_error', 'We couldn\'t update your profile, pelase try again or contactu us if situation repeats.');
             }
         } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
             echo 'User with this login already exists.';
         } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
             echo 'User was not found.';
         }
     }
     return Redirect::to('/user/edit')->withInput()->withErrors($validator)->with('message', 'Validation Errors!');
 }
开发者ID:Belar,项目名称:eventpotion,代码行数:51,代码来源:UserController.php

示例7: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function update($id)
 {
     $rules = ['slot' => 'Integer', 'memory' => 'Integer|Min:128|Max:10240', 'status' => 'Required', 'ip' => 'Required', 'port' => 'Integer|Min:1024|Max:65534|Required', 'displayName' => '', 'user' => 'Required|Exists:users,id'];
     $v = Validator::make(Input::all(), $rules);
     if ($v->passes()) {
         $user = User::find(Input::get('user'));
         $game = Game::find(Input::get('game'));
         /** @var Gameserver $gameserver */
         $gameserver = Gameserver::findOrFail($id);
         $gameserver->fill(Input::all());
         /** @var GameserverIp $ipport */
         $ipport = $gameserver->ipport;
         if ($gameserver->ipport->ip->id != Input::get('ip')) {
             $ipport->ip()->associate(Ip::findOrFail(Input::get('ip')));
             $ipport->save();
         }
         if ($gameserver->ipport->port != Input::get('port')) {
             $ipport->port = Input::get('port');
             $ipport->save();
         }
         $gameserver->user()->associate($user);
         if ($gameserver->game->id != $game->id) {
             $gameserver->game()->associate($game);
         }
         $gameserver->save();
         return Redirect::action('GameserverController@index');
     } else {
         return Redirect::action('GameserverController@update', $id)->withErrors($v->getMessageBag());
     }
 }
开发者ID:sammy8806,项目名称:gsi_laravel,代码行数:37,代码来源:GameserverController.php

示例8: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $event = ep\Event::find($id);
     // Fetch all request data.
     $data = Input::only('title', 'event_icon', 'lan', 'games', 'website', 'brackets', 'ticket_store', 'vod', 'start_date', 'finish_date', 'prizepool', 'location', 'about', 'tags', 'public_state', 'streams');
     // Build the validation constraint set.
     $rules = array('title' => array('required', 'min:3'), 'event_icon' => array('required', 'alpha_dash'), 'lan' => array('integer'), 'games' => array('required'), 'website' => array('url'), 'brackets' => array('url'), 'ticket_store' => array('url'), 'vod' => array('url'), 'start_date' => array('required', 'date', 'before:' . Input::get('finish_date')), 'finish_date' => array('required', 'date'), 'prizepool' => array('max:20'), 'location' => array('required_if:lan,true', 'max:25'), 'about' => array('max:21800'), 'public_state' => array('integer'), 'streams' => array('requiredOrArray', 'alpha_dashOrArray'));
     // Create a new validator instance.
     $validator = Validator::make($data, $rules);
     if ($validator->passes()) {
         $title = Input::get('title');
         if ($event->title !== $title) {
             $uniqid = str_shuffle(uniqid());
             $event->slug = Str::slug($title, '-') . '-' . $uniqid;
             $event->title = $title;
         }
         $event->event_icon = Input::get('event_icon');
         $event->website = Input::get('website');
         $event->brackets = Input::get('brackets');
         $event->ticket_store = Input::get('ticket_store');
         $event->vod = Input::get('vod');
         $event->start_date = new DateTime(Input::get('start_date'));
         $event->finish_date = new DateTime(Input::get('finish_date'));
         $event->prizepool = Input::get('prizepool');
         $event->about = Input::get('about');
         $event->tags = Input::get('tags');
         $event->lan = Input::get('lan') ? 1 : 0;
         if (Input::get('lan') == true) {
             $event->location = Input::get('location');
             $event->latitude = Input::get('latitude');
             $event->longitude = Input::get('longitude');
         } else {
             $event->location = 'Online';
             $event->latitude = '';
             $event->longitude = '';
         }
         $event->public_state = Input::get('public_state') ? 1 : 0;
         $event->save();
         $event_games = $event->eventGame()->get();
         $games = Input::get('games');
         foreach ($event_games as $event_game) {
             if (!in_array($event_game->id, $games)) {
                 $event->eventGame($event_game)->detach();
             }
         }
         foreach ($games as $game) {
             $game_attach = Game::find($game);
             if (!$event->eventGame()->where('game_id', '=', $game_attach->id)->first()) {
                 $event->eventGame()->attach($game_attach);
             }
         }
         $event_streams = $event->eventStream()->get();
         $stream_urls = Input::get('streams');
         foreach ($event_streams as $event_stream) {
             if (!in_array($event_stream->stream_url, $stream_urls)) {
                 $event->eventStream($event_stream)->detach();
             }
         }
         foreach ($stream_urls as $stream_url) {
             $stream_old = Stream::where('stream_url', '=', $stream_url)->first();
             if ($stream_old == false && $stream_url) {
                 $stream = new Stream();
                 $stream->stream_url = $stream_url;
                 $stream->save();
                 $stream->streamEvent()->attach($event);
             } else {
                 if (!$event->eventStream()->where('stream_id', '=', $stream_old->id)->first()) {
                     $stream_old->streamEvent()->attach($event);
                 }
             }
         }
         return Redirect::to('/')->with('global_success', 'Event submitted successfuly!');
     }
     return Redirect::to('/event/edit/' . $event->id)->withInput()->withErrors($validator)->with('message', 'Validation Errors!');
 }
开发者ID:Belar,项目名称:eventpotion,代码行数:81,代码来源:EventController.php

示例9: v14

 public function v14()
 {
     // Regenerate cache
     Cache::clear(false);
     /*
      * API
      */
     // Copy bridge secret key to API private key
     $bridge = json_decode($this->Setting->getOption('bridge'));
     if (!empty($bridge) && $bridge->enabled && !empty($bridge->secret)) {
         $api = array();
         $api['enabled'] = 0;
         $api['privateKey'] = $bridge->secret;
         $this->Setting->setOption('api', json_encode($api));
         // Disable bridge to make use users update their bridge plugin
         $bridgeSettings = array();
         $bridgeSettings['enabled'] = 0;
         $bridgeSettings['url'] = $bridge->url;
         $this->Setting->setOption('bridge', json_encode($bridgeSettings));
         $this->Session->setFlash(__('Bridge has been disabled ! Be sure to use an updated version of your bridge plugin for MushRaider 1.4. If you don\'t you\'re gonna have a bad time !'), 'flash_important', array(), 'important');
     }
     /*
      * Import
      */
     // Add absolute path to games's logo field to prepare import functionallity
     App::uses('Game', 'Model');
     $GameModel = new Game();
     $params = array();
     $params['recursive'] = -1;
     $params['fields'] = array('id', 'logo');
     if ($games = $GameModel->find('all', $params)) {
         foreach ($games as $game) {
             if (!empty($game['Game']['logo']) && strpos($game['Game']['logo'], '/files/') === false) {
                 $toUpdate = array();
                 $toUpdate['id'] = $game['Game']['id'];
                 $toUpdate['logo'] = '/files/logos/' . $game['Game']['logo'];
                 $GameModel->create();
                 $GameModel->save($toUpdate);
             }
         }
     }
     /*
      * Roles permissions
      */
     // Add roles permissions
     $rolesPermissions = array(array('title' => __('Full permissions'), 'alias' => 'full_permissions', 'description' => __('Like Chuck Norris, he can do anything. This overwrite every permissions')), array('title' => __('Limited admin access'), 'alias' => 'limited_admin', 'description' => __('Like Robin, he can do some things but not all (like driving the batmobile or change user role)')), array('title' => __('Can manage events'), 'alias' => 'manage_events', 'description' => __('Can create, edit and delete events. Can also manage the roster for each events')), array('title' => __('Can create templates'), 'alias' => 'create_templates', 'description' => __('Can create events templates')), array('title' => __('Can create reports'), 'alias' => 'create_reports', 'description' => __('Can create events reports')));
     App::uses('RolePermission', 'Model');
     $RolePermissionModel = new RolePermission();
     foreach ($rolesPermissions as $rolesPermission) {
         $RolePermissionModel->create();
         $RolePermissionModel->save($rolesPermission);
     }
     // Add new roles permissions to existing roles
     App::uses('Role', 'Model');
     $RoleModel = new Role();
     App::uses('RolePermissionRole', 'Model');
     $RolePermissionRoleModel = new RolePermissionRole();
     $RolePermissionRoleModel->__add(array('role_id' => $RoleModel->getIdByAlias('admin'), 'role_permission_id' => $RolePermissionModel->getIdByAlias('full_permissions')));
     $RolePermissionRoleModel->__add(array('role_id' => $RoleModel->getIdByAlias('officer'), 'role_permission_id' => $RolePermissionModel->getIdByAlias('limited_admin')));
     $RolePermissionRoleModel->__add(array('role_id' => $RoleModel->getIdByAlias('officer'), 'role_permission_id' => $RolePermissionModel->getIdByAlias('manage_events')));
     $RolePermissionRoleModel->__add(array('role_id' => $RoleModel->getIdByAlias('officer'), 'role_permission_id' => $RolePermissionModel->getIdByAlias('create_templates')));
     $RolePermissionRoleModel->__add(array('role_id' => $RoleModel->getIdByAlias('officer'), 'role_permission_id' => $RolePermissionModel->getIdByAlias('create_reports')));
 }
开发者ID:Chaoslan,项目名称:mushraider,代码行数:63,代码来源:PatcherController.php

示例10: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $show = Show::find($id);
     $data = Input::only('title', 'show_icon', 'games', 'stream', 'people', 'vods', 'start_date', 'about', 'tags');
     // Build the validation constraint set.
     $rules = array('title' => array('required', 'min:3'), 'show_icon' => array('required', 'alpha_dash'), 'games' => array('required'), 'start_date' => array('required', 'date'), 'people' => array('required'), 'about' => array('max:21800'), 'stream' => array('alpha_dash'), 'vods' => array('max:21800'));
     // Create a new validator instance.
     $validator = Validator::make($data, $rules);
     if ($validator->passes()) {
         $title = Input::get('title');
         if ($show->title !== $title) {
             $uniqid = str_shuffle(uniqid());
             $show->slug = Str::slug($title, '-') . '-' . $uniqid;
             $show->title = $title;
         }
         $show->show_icon = Input::get('show_icon');
         $show->air_date = new DateTime(Input::get('start_date'));
         $show->people = Input::get('people');
         $show->about = Input::get('about');
         $show->tags = Input::get('tags');
         $show->vods = Input::get('vods');
         $show->save();
         $show_games = $show->showGame()->get();
         $games = Input::get('games');
         foreach ($show_games as $show_game) {
             if (!in_array($show_game->id, $games)) {
                 $show->showGame($show_game)->detach();
             }
         }
         foreach ($games as $game) {
             $game_attach = Game::find($game);
             if (!$show->showGame()->where('game_id', '=', $game_attach->id)->first()) {
                 $show->showGame()->attach($game_attach);
             }
         }
         $show_stream = $show->showStream()->first();
         $stream_url = trim(Input::get('stream'));
         if ($show_stream && $show_stream->stream_url !== $stream_url) {
             $show->showStream($show_stream)->detach();
         } elseif ($show_stream && $stream_url == false) {
             $show->showStream($show_stream)->detach();
         }
         if ($stream_url) {
             $stream_old = Stream::where('stream_url', '=', $stream_url)->first();
             if ($stream_old == false && $stream_url) {
                 $stream = new Stream();
                 $stream->stream_url = $stream_url;
                 $stream->save();
                 $stream->streamShow()->attach($show);
             } else {
                 if (!$show->showStream()->where('stream_id', '=', $stream_old->id)->first()) {
                     $stream_old->streamShow()->attach($show);
                 }
             }
         }
         return Redirect::to('/')->with('global_success', 'Show submitted successfuly!');
     }
     return Redirect::to('/show/edit/' . $show->id)->withInput()->withErrors($validator)->with('message', 'Validation Errors!');
 }
开发者ID:Belar,项目名称:eventpotion,代码行数:65,代码来源:ShowController.php

示例11: edit

 /**
  * Show the form for editing the specified game.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $game = Game::find($id);
     return View::make('games.edit', compact('game'));
 }
开发者ID:orbitroom,项目名称:4isk,代码行数:11,代码来源:GamesController.php

示例12: edit

 public static function edit($id)
 {
     $game = Game::find($id);
     View::make('game/edit.html', array('attributes' => $game));
 }
开发者ID:Hannav,项目名称:Joogailmo,代码行数:5,代码来源:tunti_controller.php

示例13: show

 /**
  * Renvoi un matche
  *
  * @return Response
  */
 public function show($id)
 {
     return Response::json(array('success' => true, 'payload' => Game::find($id)->toArray()));
 }
开发者ID:Cclleemm,项目名称:worldcup,代码行数:9,代码来源:GameController.php

示例14: sendStats

 private function sendStats()
 {
     $stats = array();
     // Website
     $stats['Website']['url'] = Router::url('/', true);
     $stats['Website']['version'] = Configure::read('mushraider.version');
     $stats['Website']['php'] = phpversion();
     $stats['Website']['lang'] = Configure::read('Settings.language');
     // Events
     App::uses('Event', 'Model');
     $EventModel = new Event();
     $params = array();
     $params['recursive'] = -1;
     $params['order'] = array('time_start ASC');
     if ($firstEvent = $EventModel->find('first', $params)) {
         $stats['Event']['first'] = $firstEvent['Event']['time_start'];
     } else {
         $stats['Event']['first'] = null;
     }
     $params['conditions']['time_start <='] = date('Y-m-d');
     $params['order'] = array('time_start DESC');
     if ($lastEvent = $EventModel->find('first', $params)) {
         $stats['Event']['last'] = $lastEvent['Event']['time_start'];
     } else {
         $stats['Event']['last'] = null;
     }
     $params = array();
     $params['recursive'] = -1;
     $params['conditions']['time_start <='] = date('Y-m-d');
     $countEvents = $EventModel->find('count', $params);
     $stats['Event']['total'] = $countEvents;
     // Reports
     App::uses('Report', 'Model');
     $ReportModel = new Report();
     $params = array();
     $params['recursive'] = -1;
     $countReports = $ReportModel->find('count', $params);
     $stats['Report']['total'] = $countReports;
     // Users
     App::uses('User', 'Model');
     $UserModel = new User();
     $params = array();
     $params['recursive'] = -1;
     $countUsers = $UserModel->find('count', $params);
     $stats['User']['total'] = $countUsers;
     // Characters
     App::uses('Character', 'Model');
     $CharacterModel = new Character();
     $params = array();
     $params['recursive'] = -1;
     $countCharacters = $CharacterModel->find('count', $params);
     $stats['Character']['total'] = $countCharacters;
     // Games
     App::uses('Game', 'Model');
     $GameModel = new Game();
     $params = array();
     $params['recursive'] = -1;
     if ($games = $GameModel->find('all', $params)) {
         foreach ($games as $game) {
             $stats['Game'][$game['Game']['slug']]['title'] = $game['Game']['title'];
             $stats['Game'][$game['Game']['slug']]['imported'] = $game['Game']['import_modified'] > 0 ? 1 : 0;
             $params = array();
             $params['recursive'] = -1;
             $params['conditions']['game_id'] = $game['Game']['id'];
             $params['group'] = array('user_id');
             $countCharacters = $CharacterModel->find('count', $params);
             $stats['Game'][$game['Game']['slug']]['players'] = $countCharacters;
         }
     }
     // Bridge
     $bridgeSetting = json_decode($this->SettingModel->getOption('bridge'));
     $stats['Bridge']['enabled'] = !empty($bridgeSetting) && $bridgeSetting->enabled ? 1 : 0;
     // Widgets
     App::uses('Widget', 'Model');
     $WidgetModel = new Widget();
     $params = array();
     $params['recursive'] = -1;
     if ($widgets = $WidgetModel->find('all', $params)) {
         foreach ($widgets as $widget) {
             if (!isset($stats['Widget'][$widget['Widget']['controller']])) {
                 $stats['Widget'][$widget['Widget']['controller']]['total'] = 1;
             } else {
                 $stats['Widget'][$widget['Widget']['controller']]['total']++;
             }
         }
     }
     App::uses('HttpSocket', 'Network/Http');
     $this->http = new HttpSocket();
     $this->http->post('http://stats.mushraider.com/acquire', $stats);
 }
开发者ID:Chaoslan,项目名称:mushraider,代码行数:90,代码来源:MushstatsComponent.php


注:本文中的Game::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。