当前位置: 首页>>代码示例>>PHP>>正文


PHP Datatables::collection方法代码示例

本文整理汇总了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()]);
 }
开发者ID:yajra,项目名称:cms-core,代码行数:39,代码来源:UtilitiesController.php


注:本文中的Yajra\Datatables\Datatables::collection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。