laravel admin 添加序號列

$grid ->column("index",'序號');
$grid->model()->collection(function (Collection $collection)use($grid){
    $page = request('page')?:1;
    $startIndex = (($page-1)*$grid->perPage);
   foreach ($collection as $key=>$collect){
       $collect->index =$startIndex+$key+1;
   }
   return $collection;
});

只能這樣寫了,暫時不知道有啥更好的方法;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章