Laravel query with distinct() methode

  datatable, laravel

how can i get branch_id value but with different program_id condition?

$data   = Peserta::where('branch_id',$branch_id)
                ->select('program_id')->distinct()
                ->with('program','branch');
                return DataTables::of($data)
                ->addColumn('program', function ($data) {
                    return $data->program->name;
                })
                ->addColumn('action', function ($data) {
                    $btn = '<a href="/halaman-data-peserta-berdasarkan-cabang-dan-program/'.$branch_id.'/'.$data->program->id.'" class="btn btn-sm btn-info"> check </a>';
                    return $btn;
                })
                ->rawColumns(['program','action'])
                ->make(true);

Source: Laravel

Leave a Reply