在 table laravel 5.8 上显示时如何更改值

how change the value when show on the table laravel 5.8

当 table blade 中出现时,我尝试将 jenis_id (int) 更改为字符串。 the value in the database 这是我的尝试

@if($ad->jenis_id = '1')
    <td>Terkait</td>
@elseif ($ad->jenis_id = '2')
    <td>Informasi</td>
@endif

but only "terkait" show in column

运算符不是 = 来比较...使用 == 如:

@if($ad->jenis_id == 1)
    <td>Terkait</td>
@elseif ($ad->jenis_id == 2)
    <td>Informasi</td>
@endif

希望对您有所帮助!

您的问题是单个 = 字符。您只需将一个值分配给 属性 而不是比较。您应该考虑使用 =====。第一个只检查值,因此强制占有一席之地。三重相等 char 检查值和类型。