i have a table that is displaying the value from an integer field. so the app works like this: the user selects an option from the radio selection, each value is an integer, so 1 is math, 2 is english and 3 is spanish. However in my table field, it just shows the number when displaying the table in a view, how can i make it such that 1 in the db table shows math on the view?
heres my table code:
@foreach ( $subject as $code) <tr> <td>{{$code->subjectType}}</td> </tr> @endforeach
Advertisement
Answer
Try this:
<?php $subjectCodes = [1=>'Math', 2=>'English', 3=>'Spanish']; ?> @foreach ( $subject as $code) <tr> <td>{{$subjectCodes[$code->subjectType]}}</td> </tr> @endforeach