-1
I have the following code in my controller funcionarios::with('user', 'rh')->get()
returns all beautiful related data but only the first record is really related sure the others in the RH relationship does not list the RH data comes without anything an empty array.
Follow the model code:
class funcionarios extends Model
{
protected $table = 'funcionarios';
protected $fillable = [
'sexo',
'celular',
'matricula',
'ramal'
];
protected $hidden = [];
public function rh()
{
return $this->belongsToMany(\App\RH::class, 'funcionario_rh', 'rh_id', 'funcionario_id');
}
public function user() {
return $this->hasOne(\App\User::class, 'id', 'user_id');
}
}
I leave alerted that the entries are correct in the bank the way they should be done and are registering everything, the real problem is in the listing.