本文整理汇总了PHP中Yajra\Datatables\Datatables::collection方法的典型用法代码示例。如果您正苦于以下问题:PHP Datatables::collection方法的具体用法?PHP Datatables::collection怎么用?PHP Datatables::collection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Yajra\Datatables\Datatables
的用法示例。
在下文中一共展示了Datatables::collection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logs
/**
* Log viewer.
*
* @param \Illuminate\Http\Request $request
* @param \Yajra\Datatables\Datatables $datatables
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View|\Symfony\Component\HttpFoundation\BinaryFileResponse
* @throws \Exception
*/
public function logs(Request $request, Datatables $datatables)
{
if ($request->input('l')) {
LaravelLogViewer::setFile(base64_decode($request->input('l')));
}
if ($request->input('dl')) {
return response()->download(LaravelLogViewer::pathToLogFile(base64_decode($request->input('dl'))));
} elseif ($request->has('del')) {
File::delete(LaravelLogViewer::pathToLogFile(base64_decode($request->input('del'))));
return redirect()->to($request->url());
}
$logs = LaravelLogViewer::all();
if ($request->wantsJson()) {
return $datatables->collection(collect($logs))->editColumn('stack', '{!! nl2br($stack) !!}')->editColumn('level', function ($log) {
$content = $this->html->tag('span', '', ['class' => "glyphicon glyphicon-{$log['level_img']}-sign"]);
$content .= ' ' . $log['level'];
return $this->html->tag('span', $content, ['class' => "text-{$log['level_class']}"]);
})->addColumn('content', function ($log) {
$html = '';
if ($log['stack']) {
$html = '<a class="pull-right expand btn btn-default btn-xs"><span class="glyphicon glyphicon-search"></span></a>';
}
$html .= $log['text'];
if (isset($log['in_file'])) {
$html .= '<br>' . $log['in_file'];
}
return $html;
})->make(true);
}
return view('administrator.utilities.log', ['logs' => $logs, 'files' => LaravelLogViewer::getFiles(true), 'current_file' => LaravelLogViewer::getFileName()]);
}