我的视图中的查询未执行。来自->select('name')
它只是在我的网站上显示为纯文本。
<tbody>
@foreach($getdeaths as $getdeath)
<tr>
<? DB::table('players')->select('name')->where('id', $getdeath->player_id)->get(); ?>
<td>{{ $getdeath->player_id }}</td>
<td>{{ $getdeath->level }}</td>
<td>{{ date("d F Y (H:i)", strtotime($getdeath->time)) }}</td>
<td>@if($getdeath->is_player == 1)
{{ '<a href="characters/'.$getdeath->killed_by.'">'.$getdeath->killed_by.'</a> (PVP)' }}
@else
{{ $getdeath->killed_by }}
@endif</td>
</tr>
@endforeach
</tbody>
答案 0 :(得分:0)
更改
<? DB::table('players')->select('name')->where('id', $getdeath->player_id)->get(); ?>
到
<?= DB::table('players')->where('id', $getdeath->player_id)->pluck('name'); ?>
<?
表示php
<?=
表示php echo
您可以保存var并像平常一样回显它:
{{ $x=DB::table('players')->where('id', $getdeath->player_id)->pluck('name'); }}
{{ $x }}