我想在我的主表单数据中显示另一个表中的数据表数据。
该关系已经在所有相关模型中定义,我现在想使用数据表在[公司主数据]内部的[公司员工标签]中显示员工/ p>
我只想过滤/仅显示已打开公司的数据
== 这是CompanyManagementController == [员工]
public function getManagement()
{
return DataTables::of(CompanyManagement::query())
->editColumn('name', function (CompanyManagement $management) {
return $management->name;
})
->editColumn('party_id', function (CompanyManagement $management) {
return $management->party->name;
})
->editColumn('phone', function (CompanyManagement $management) {
return $management->phone;
})
->editColumn('email', function (CompanyManagement $management) {
return $management->email;
})
->editColumn('management_role_id', function (CompanyManagement $management) {
return $management->managementRole->name;
})
->editColumn('additional_info', function (CompanyManagement $management) {
return $management->additional_info;
})
->rawColumns(['action'])
->addColumn('action', function ($id) {
return '<a href="management/' . $id->id . '" class="btn btn-xs btn-primary ">Edit</a>';
})
->make(true);
}
**脚本的数据表路由**
Route::get('getmanagement', 'CommpanyManagementController@getManagement')->name('get.management');
**刀片脚本**
$(function() {
$('#management').DataTable({
processing: true,
serverSide: true,
ajax: '{!! route('get.management') !!}',
columns: [
{ data: 'name', name: 'name' },
{ data: 'management_role_id', name: 'management_role_id' },
{ data: 'additional_info', name: 'additional_info' },
{ data: 'party_id', name: 'party_id' },
{ data: 'phone', name: 'phone' },
{ data: 'email', name: 'email' },
{ data: 'action', name: 'action' }
],
});
});