本文整理汇总了PHP中Room::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Room::find方法的具体用法?PHP Room::find怎么用?PHP Room::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Room
的用法示例。
在下文中一共展示了Room::find方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: join
public function join()
{
$data = Input::only(['name', 'room_id']);
print_r($data);
$room = Room::find($data['room_id']);
if (!$room) {
return Redirect::action('PrepareController@room');
}
if ($room->state !== 'open') {
throw new BadRequestHttpException('既にゲームは開始しています。');
}
if ($room->mates->count() >= $room->member_number) {
throw new BadRequestHttpException('全ユーザーが揃っています');
}
if (!isset($data['name']) || $data['name'] == '') {
//名前指定していない場合
return Redirect::action('PrepareController@rooms');
}
$i = 0;
do {
$hash = sha1(date("Y/m/d H:i:s.u") . 'zCeZu12X' . $data['name'] . $data['room_id']);
$hashed_mate = Mate::where('hash', $hash)->select('hash')->first();
$i++;
if ($i > 50) {
throw new InternalErrorException('ユーザー作成に失敗しました hash衝突しまくり');
}
} while ($hashed_mate && $i < 100);
$mate = Mate::create(['name' => $data['name'], 'last_state' => 'open', 'hash' => $hash, 'cast_id' => 0, 'room_id' => $data['room_id'], 'select_user_id' => '', 'is_alive' => 1]);
if (!$mate) {
throw new InternalErrorException('ユーザー作成に失敗しました');
}
$room->touch();
return Redirect::action('PlayController@index', ['hash' => $hash]);
}
示例2: getDelete
public function getDelete($id)
{
$room = Room::find($id);
$room->delete();
Session::flash('message', 'The records are deleted successfully');
return Redirect::to('rooms');
}
示例3: deleteRoom
public function deleteRoom($buildingid, $id)
{
//
$room = Room::find($id);
$room->delete();
return Redirect::to('/building/' . $buildingid);
}
示例4: getMap
/**
* Show the form for editing the specified room.
*
* @param int $id
* @param int $channelId
* @return Response
*/
public function getMap($id, $channelId)
{
$room = Room::find($id);
$channelSettings = PropertiesChannel::getSettings($channelId, Property::getLoggedId());
$channel = ChannelFactory::create($channelSettings);
$result = $channel->getInventoryList();
//todo temp
// file_put_contents('1.txt', serialize($result));
// $result = unserialize(file_get_contents('1.txt'));
//add Inventories and Plans to DB//TODO move to another place
//delete exist maps
Inventory::where(['channel_id' => $channelId, 'property_id' => $channelSettings->property_id])->delete();
//delete exist plan maps
InventoryPlan::where(['channel_id' => $channelId, 'property_id' => $channelSettings->property_id])->delete();
if ($result) {
foreach ($result as $inventory) {
Inventory::create(['code' => $inventory['code'], 'name' => $inventory['name'], 'channel_id' => $channelId, 'property_id' => $channelSettings->property_id]);
if ($inventory['plans']) {
foreach ($inventory['plans'] as $plan) {
InventoryPlan::create(['code' => $plan['code'], 'name' => $plan['name'], 'channel_id' => $channelId, 'inventory_code' => $inventory['code'], 'property_id' => $channelSettings->property_id]);
}
}
}
}
$existMapping = [];
// $mapCollection = InventoryMap::where(
// [
// 'channel_id' => $channelId,
// 'property_id' => $channelSettings->property_id
// ]
// )
//// ->where('room_id', '<>', $id)
// ->lists('inventory_code', 'room_id');
// if ($mapCollection) {
// foreach ($mapCollection as $map) {
// $existMapping[] = $map;
// }
// }>F
$inventories = Channel::find($channelId)->inventory()->where('property_id', Property::getLoggedId());
$inventoryList = [];
$inventoryPlans = [];
foreach ($inventories->get() as $inventory) {
// if (in_array($inventory->code, $existMapping)) {
// continue;
// }
$inventoryList[$inventory->code] = $inventory->name;
$plans = $inventory->plans()->get(['name', 'code']);
for ($i = 0; $i < count($plans); $i++) {
//TODO rewrite to ONE query
$plans[$i]->selected = InventoryMap::getByKeys($channelId, $channelSettings->property_id, $id, $plans[$i]['code'])->first() ? true : false;
}
$inventoryPlans[$inventory->code] = $plans;
}
$inventoryPlans = json_encode($inventoryPlans);
$mapping = InventoryMap::getByKeys($channelId, $channelSettings->property_id, $id)->first();
return View::make('rooms.map', compact('room', 'channel', 'inventoryList', 'inventoryPlans', 'channelId', 'mapping'));
}
示例5: ajax_loadRoom
public function ajax_loadRoom()
{
$query = $this->__getQuery();
$returnCode = new AjaxReturn();
if (!$this->__initInfoFromQuery()) {
return $returnCode->error('room is missing');
}
if (!$this->__joinsThisRoom()) {
return $returnCode->error('not joined the room');
}
$callTime = 0;
while ($callTime < 30) {
// masterのみの追加処理
if ($this->myInfo->ismaster()) {
if ($this->__checkState() === 'open' && $this->room->sitDownAllMate()) {
$this->__advanceState('open');
break;
}
//状態が変化した場合に、情報を知らせる
if ($this->__hasChangedState()) {
if (isset($this->room->last_dead_user_id)) {
$returnCode->add('dead', $this->room->last_dead_user_id);
break;
}
} else {
if ($this->room->state == 'end') {
$returnCode->add('result', $this->__checkTriumph());
break;
}
}
//最後に全員が選択済みであれば自動的に進める
$result = $this->__allSelectStateFlow();
$result |= $this->__timedStateFlow();
if ($result) {
break;
}
// master is clear
if ($this->__checkstate() === 'open' && $this->room->sitdownallmate()) {
$this->__advancestate('open');
break;
}
}
// 初回のみLongPollingなし
if (!isset($query['state']) || $query['state'] === '') {
break;
}
$newRoom = Room::find($this->room->id);
if ($newRoom->updated_at > $this->room->updated_at) {
$this->room = $newRoom;
$this->room->mates = Mate::where('room_id', $newRoom->id)->get();
break;
}
$callTime += 3;
usleep(3000 * 1000);
}
//$returnCode->add('jsstate', $this->getJSState());
$returnCode->add('state', $this->__getState());
$returnCode->add('room', $this->room);
$returnCode->add('mates', $this->room->mates);
$returnCode->add('myInfo', $this->myInfo);
$returnCode->add('myCast', $this->myInfo->cast);
//print_r($this->myInfo->cast());
return $returnCode->success();
}
示例6: post_delete
public function post_delete($city, $id, $delkey)
{
$rules = array('id' => 'required', 'delkey' => 'required|max:60', 'email' => 'required|email');
$values = array('id' => $id, 'delkey' => $delkey, 'email' => Input::get('email'));
$v = Validator::make($values, $rules);
$room = Room::find($id);
if ($v->fails()) {
return View::make('home.room')->with('del', '<div id="delModal" class="modal hide" tabindex="-1" role="dialog" aria-hidden="true"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><h3 id="myModalLabel">Kamer verwijderen</h3></div><div class="modal-body"><p>Vul ter verificatie je e-mailadres in om de kamer te verwijderen.</p><form action="' . $delkey . '" method="post" class="form-horizontal"><div class="control-group"><label class="control-label" for="email">Email:</label><div class="controls"><input type="email" name="email" class="span8" placeholder="Je e-mail" data-validations="required|email"><p class="error-bottom">Vul a.u.b een emailadres in</p></div></div><div class="control-group"><label class="control-label" for="reason">Reden:</label><div class="controls"><label class="radio"><input type="radio" name="reason" value="Verhuurd"> <strong>Huisgenoot gevonden, bedankt!</strong></label><label class="radio"><input type="radio" name="reason" value="Andere kamerwebsite"> Verhuurd via andere kamerwebsite</label><label class="radio"><input type="radio" name="reason" value="Geen reacties"> Geen reacties gekregen</label><label class="radio"><input type="radio" name="reason" value="Ontevreden"> Ontevreden over kamergenood</label></div></div></div><div class="modal-footer"><button class="btn btn-danger" type="submit">Verwijder kamer</button></form></div></div>')->with('room', $room);
} else {
if ($room->delkey == $delkey && $room->email == Input::get('email')) {
$room->delete();
$path_kamer_folder = 'public_html/img/room/' . $id;
File::rmdir($path_kamer_folder);
return Redirect::to('kamer-verhuren');
} else {
return View::make('home.room')->with('del', '<div id="delModal" class="modal hide" tabindex="-1" role="dialog" aria-hidden="true"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><h3 id="myModalLabel">Kamer verwijderen</h3></div><div class="modal-body"><div class="alert alert-error"><strong>Onjuist emailadres!</strong> Dit emailadres is niet bekend bij ons
</div><form action="' . $delkey . '" method="post" class="form-horizontal"><div class="control-group"><label class="control-label" for="email">Email:</label><div class="controls"><input type="email" name="email" class="span8" placeholder="Je e-mail" data-validations="required|email"></div></div><div class="control-group"><label class="control-label" for="reason">Reden:</label><div class="controls"><label class="radio"><input type="radio" name="reason" value="Verhuurd"> <strong>Huisgenoot gevonden, bedankt!</strong></label><label class="radio"><input type="radio" name="reason" value="Andere kamerwebsite"> Verhuurd via andere kamerwebsite</label><label class="radio"><input type="radio" name="reason" value="Geen reacties"> Geen reacties gekregen</label><label class="radio"><input type="radio" name="reason" value="Ontevreden"> Ontevreden over kamergenood</label></div></div></div><div class="modal-footer"><button class="btn btn-danger" type="submit">Verwijder kamer</button></form></div></div>')->with('room', $room);
}
}
}
示例7: getPrice
public function getPrice($id)
{
$data = Room::find($id);
$array[] = array('number' => $data->number, 'price' => $data->type->price);
echo json_encode($array);
}
示例8: __checkTriumph
protected function __checkTriumph()
{
$remainNumbers = ['jinroh' => 0, 'people' => 0];
$latestRoomData = Room::find($this->room->id);
foreach ($latestRoomData->mates->all() as $mate) {
if ($mate->is_alive == 0) {
continue;
}
if ($latestRoomData->last_dead_user_id === $mate->id) {
continue;
}
if ($mate->cast->jinroh_team == 1) {
$remainNumbers['jinroh']++;
} else {
$remainNumbers['people']++;
}
}
if ($remainNumbers['jinroh'] <= 0) {
return 'people';
//市民の勝利
} else {
if ($remainNumbers['people'] <= $remainNumbers['jinroh']) {
return 'jinroh';
//人狼の勝利
}
}
return null;
// 勝負がついていない
}
示例9: get_edit
public function get_edit($id)
{
$room = Room::find($id);
return View::make('admin.rooms.edit')->with('room', $room);
}
示例10: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
// delete
$room = Room::find($id);
$room->delete();
// redirect
Session::flash('message', 'Successfully deleted the room!');
return Redirect::to('rooms');
}