// $data[$num]['username'] = $li->user->name; // $data[] = $li; //// $data[$num] = $li; //// $data[$num]['status'] = $li->with('statusdef')->get(); //// $data[$num] = App\LotInfo::with('statusdef')->where('lot_id', $num)->orderBy('created_at', 'DESC')->first(); //// $data[$num] = App\LotInfo::where('lot_id', $num)->orderBy('created_at', 'DESC')->first(); //// $data[$num] = $li->where('lot_id', $num)->orderBy('created_at', 'DESC')->first(); // } // $data = collect($data); // $lotinfos = $lis->map(function($li) { // return $li->lot_num = $li->lot_name; // }); // $lis = $lis // dd($lotinfos); $megalis = App\LotInfo::whereIn('lot_id', DB::table('lot_defs')->select('id')->where('map_id', 2)->distinct()->pluck('id')); $data = LotDef::query()->where('map_id', 2)->with('latestlotinfo', 'latestlotinfo.statusdef', 'latestlotinfo.user', 'latestlotinfo.buildtype')->get(); // dd($data); // $data = App\LotInfo::whereIn('lot_id', $lots) // ->orderBy('created_at', 'desc')->first() // ->groupBy('lot_num') // ->distinct() // ->with( // [ // 'statusdef', // 'buildtype', // 'user' // ]); // // Initiate by a database query // return DataGrid::make(DB::table('cities'), $columns, $settings); // // Or by an Eloquent model query // return DataGrid::make(with(new City)->newQuery(), $columns, $settings);