dimanche 9 décembre 2018

laravel concatenate in Repository

hi i have table name consultation with foriegn key of table patient in my index blade it s yajra datatable i show first name of patient but i want to show full name (first and last name) fonction in repository file

 public function getForDataTable()
{
    return $this->query()
        ->leftjoin(config('module.patients.table'), config('module.patients.table').'.id', '=', config('module.consultations.table').'.patient_id')
        ->select([
            config('module.consultations.table').'.id',
            config('module.consultations.table').'.patient_id',
            config('module.consultations.table').'.motif',
            config('module.consutations.table').'.date_consultation',
            config('module.consultations.table').'.examen_paraclinique',
            config('module.consultations.table').'.created_at',
            config('module.consultations.table').'.updated_at',
            config('module.patients.table').'.nom_patient as patient_id',
        ]);

}

my ajax code

 {data: 'patient_id', name: '.nom_patient'}, 

my resource file

 'patient_id' =>is_int($this->patient_id) ? optional($this->ownerPat)->nom_patient : $this->patient_id,

thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire