I need to extract some datas from a table;
the cleanest way:
$levels = Cga_company_level::where(['company_uuid' => $companyUuid])->get()->pluck('cgaLevel');
the second cleanest way:
$levels = Cga_company_level::where(['company_uuid' => $companyUuid])->get();
$levelIds= $companyLevelsByUuids->pluck('cga_level_id');
$levels= Cga_level::whereIn('cga_level_id',$levelIds)->get();
the old school way:
$companyLevelsByUuids = Cga_company_level::where(['company_uuid' => $companyUuid])->with('cgaLevel')->get();
$levels = [];
foreach ($companyLevelsByUuids as $companyLevel) {
$level = $companyLevel->cgaLevel;
$levels[] = $level;
}
any other smartest way?
