【发布时间】:2020-12-19 10:35:00
【问题描述】:
嗨论坛如何将 created_at 列转换为标题表并将其与标题列同步。 这是我的数据库
下面是我的刀片代码
<div class="container">
<table class="table table-striped">
<thead>
<tr>
<th>No</th>
<th>Name</th>
@foreach($users as $u=>$user)
@foreach($user->posts as $p)
<th>{{$p->created_at}}</th>
@endforeach
@endforeach
</tr>
</thead>
<tbody>
@foreach($users as $u=>$user)
<tr>
<td>{{$u+1}}</td>
<td>{{ $user->name }}</td>
@foreach($user->posts as $p)
<td><a href ="/posts/{{$p->id}}">{{$p->title}}</a></td>
</tr>
@endforeach
</tbody>
</table>
</div>
我有 2 个表,用户表和发布表。一个用户可以有很多帖子。
这是我的帖子模型
这是我的用户模型
这是我的帖子控制器
谢谢。
【问题讨论】:
-
你的问题不太清楚。请将您的代码添加为代码而不是图像。并使用您预期的输出格式更具体地解释您的问题。
-
代码不要放图片,代码是文字,可以复制粘贴到代码块中
标签: php html mysql laravel eloquent