Laravel 4 input option -
i've got controller code says:
$player->town_id = $input['town']; // located in config.lua $player->posx = '95'; // posx (x) $player->posy = '117'; // posy (y) $player->posz = '7'; // posz (z)
also here's view (part of view need):
<div class="control-group"> {{ form::label('town', 'town:') }} <div class="controls"> {{ form::select('town', array('1' => 'main town', '2' => 'second town'), '1'); }} </div> </div>
you see, want set config or if statement. if town set main town (which equals 1) this:
$player->posx = '95'; // posx (x) $player->posy = '117'; // posy (y) $player->posz = '7'; // posz (z)
else if user selects second town (which equals 2), it'll use different postion:
$player->posx = '1000'; // posx (x) $player->posy = '1000'; // posy (y) $player->posz = '7'; // posz (z)
is there if statement or use in case?
in controller can use
// other code, assuming $player exists if(input::has('town')) { if(input::get('town') == 1) { $player->posx = '95'; $player->posy = '117'; $player->posz = '7'; } elseif(input::get('town') == 2) { $player->posx = '1000'; $player->posy = '1000'; $player->posz = '7'; } }
Comments
Post a Comment