I am trying to obtain the name of the states of the republic in a one to many relationship:
the model of States the relationship:
public function empleado(){
return $this->hasMany('App\Models\Empleado');
}
the model of the employees the relationship:
public function estados(){
return $this->belongsTo('App\Models\Estados');
}
I want to get the name of the states and print it in the view, the query is:
$state = DB::table('estados as es')
->select(' es.NOMBRE', 'em.Estado_Actual_ID')
->join('empleados as em', 'es.id', '=' ,'em.Estado_Actual_ID');
but when I want to print it:
dd($state->NOMBRE);
I get the following error:
Undefined property: Illuminate\Database\Query\Builder::$NOMBRE
what is the problem;