/** FUNCIONA **/ public static function listDoctor($clinic_id) { $datos = DB::table('doctors')->join('users', 'users.id', '=', 'doctors.user_id')->join('clinics', 'clinics.id', '=', 'doctors.clinic_id')->join('business_clinics', 'business_clinics.doctor_id', '=', 'doctors.id')->join('specialties', 'specialties.id', '=', 'doctors.specialty_id')->join('profiles', 'profiles.user_id', '=', 'users.id')->where('clinics.id', $clinic_id)->select('doctors.id as doctor_id', DB::raw('CONCAT(users.first_name," " ,users.last_name) as doctor_name'), 'business_clinics.id as local_id', 'doctors.specialty_id as specialty_id', 'profiles.picture as picture')->get(); $especialidades = array(); $dda = array(); foreach ($datos as $d) { $specialties = explode(',', $d->specialty_id); foreach ($specialties as $esp) { $espec = Specialty::find($esp); if (Helpers::lang() == 'es') { $especialidades[] = array('id' => $espec->id, 'name' => $espec->name_es); } else { $especialidades[] = array('id' => $espec->id, 'name' => $espec->name_en); } } $dda = array('doctor_id' => $d->doctor_id, 'doctor_name' => $d->doctor_name, 'local_id' => $d->local_id, 'picture' => $d->picture, 'specialties' => $especialidades); } return Response::json($dda); }