ajax - Laravel 刀片表到 AJAX
问题描述
嗨,我有很多收据和合作伙伴的用户。我需要一张这样的桌子。
ID | Receipt Number | Username | Receipt Date | Partner name| Partner Phone | Operations
这是我的控制器。用户与收据和合作伙伴有关系,他们返回我需要的结果。
public function index()
{
$user = Auth::id();
$datas = Operation::with('user','receipt', 'partner')->where('user_id', $user)->get();
return view('operations.index', compact('datas'));
}
这是视图
<table class="datatables-basic table" id="example">
<thead>
<tr>
<th>#</th>
<th></th>
<th>User</th>
<th>Date</th>
<th>Partner</th>
<th>Phone</th>
<th>Amallar</th>
</tr>
</thead>
<tbody>
@foreach($datas as $idx => $data)
<tr>
<td>{{$idx+1}}</td>
<td>{{$data->receipt->number}}</td>
<td>{{$data->user->username}}</td>
<td>{{$data->receipt->date}}</td>
<td>{{$data->partner->username}}</td>
<td>{{$data->partner->phone}}</td>
<td>
<a href="#" class="btn btn-icon btn-flat-primary">
<i class="fas fa-edit"></i>
Edit
</a>
<a href="#" class="btn btn-icon btn-flat-primary">
<i class="fas fa-view"></i>
View
</a>
<a href="#" class="btn btn-icon btn-flat-primary">
<i class="fas fa-trash"></i>
Delete
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
问题是{{$data->receipt->number}}
,,{{$data->receipt->date}}
说{{$data->partner->username}}
“此集合中不存在属性 [日期]”。
第二个问题如何将此表转换为 AJAX?
这是操作表
id| user_id | parner_id | receipt_id | date | amount | price
这是收据表
id | date | type | user_id
谢谢
解决方案
推荐阅读
- r - dplyr:在数据帧中使用连续重复 n 次的整数来改变一个新列
- javascript - 在什么情况下 'a != a' 在 JavaScript 中解析为 true?
- reactjs - Ngrok 不断与 Nextjs 重新连接
- certificate - 为什么 NET::ERR_CERT_COMMON_NAME_INVALID 在 admin.localhost 上出现 chrome 错误,SAN 和 CN 设置为 *.localhost
- android - 如何每天重置计步器?
- http - 可以利用 Content-length 标头吗?
- android - Android loadThumbnail 专辑插图 (API 29)
- javascript - 屏幕共享不适用于 getDisplayMedia
- r - 为 POSIXct 日期格式添加因子列
- php - 找不到常量 subresourceOperations,类 App\Entity\Comment