Is it possible to use switch/case or if/else in blade?
if $player->foot ="l" then $foot = "left";
If you don't the var set in the template and just want to display the other value,
<div>
@if ($player->foot == "l")
Left
@elseif ($player->foot == "r")
Right
@else
Both
@endif
</div>
Blade template reference http://laravel.com/docs/4.2/templates
Or you could check the data before and pass a display var to the view, of course that is depending on how you pass the data in.
Thanks.
Is it possible to change the data in the select in the database? (CASE)
I assume you have enum
field (l, r, b), so you can use accessor like below:
// Player model (or whatever your model is ofc)
public function getFootAttribute($value)
{
switch ($value)
{
case 'b':
return 'Both';
case 'l':
return 'Left';
default:
return 'Right';
}
}
// then
$player->foot; // returns Right / Left / Both
This is the solution. I don't know why, but it works.
Many thanks.
regards markus
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community