with([ 'store:id,market_id,name,mm_user_id', 'user'=> function($query) use($startTime,$endTime){ $query->selectRaw(DB::raw('count(distinct user_id) as new_user_total'))->whereRaw("join_time BETWEEN UNIX_TIMESTAMP('?') AND UNIX_TIMESTAMP('?')",[$startTime,$endTime]); }]) ->whereRaw("UNIX_TIMESTAMP(pay_time) BETWEEN UNIX_TIMESTAMP('?') AND UNIX_TIMESTAMP('?')",[$startTime,$endTime]) ->select('store_id') ->groupBy('store_id') ->orderBy('market_id','desc') ->orderbY('new_user_total','desc'); // return Grid::make(new StoreUserReport(), function (Grid $grid) { return Grid::make($newModel, function (Grid $grid) { $grid->disableCreateButton(); $grid->store_id; $grid->market_id; $grid->store_name; $grid->mm_user_id; $grid->new_user_total; $grid->filter(function (Grid\Filter $filter) { $filter->equal('store_id'); }); }); } /** * Make a show builder. * * @param mixed $id * * @return Show */ protected function detail($id) { return Show::make($id, new StoreUserReport(), function (Show $show) { $show->id; $show->market_id; $show->name; $show->mm_user_id; }); } /** * Make a form builder. * * @return Form */ protected function form() { return Form::make(new StoreUserReport(), function (Form $form) { $form->display('id'); $form->text('market_id'); $form->text('name'); $form->text('mm_user_id'); }); } }