1
我堅持我的addColumn
語句添加if
聲明:Laravel Yajra DataTable的if語句上addColumn
$inquiries = Inquiry::with('customer')->get();
return Datatables::of($inquiries)
->editColumn('created_at', function ($inquiry) {
return $inquiry->created_at->format('d-m-Y');
})
->editColumn('due_date', function ($inquiry) {
return Carbon::parse($inquiry->due_date)->format('d-m-Y');
})
->editColumn('status', '@if($status == 0) Pending @elseif($status == 1) Accept @else Cancel @endif')
->addColumn('action', function ($inquiry) {
return '
<a href="/inquiries/' . $inquiry->id . '" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> View</a>
<a href="/inquiries/' . $inquiry->id . '/edit" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>
<a href="#" id="delete-button" data-id="' . $inquiry->id . '" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Delete</a>
';
})
->make(true);
我試圖把@if @endif
但現在看來它打印出來,而不是成爲一個功能
我想根據狀態顯示操作按鈕。
任何解決方案?
謝謝