I'm trying to create a field relationship using eloquent de laravel, I currently have it working like this:
$empleos = Empleos::latest()->paginate(50);
return $empleos;
I return all jobs correctly, my problem is that there are fields that come from another external table, the logic would be the following:
$empleos = Empleos::latest()->paginate(50)->join('empresa','empresa.id''=','empreos.empresa');
return $empleos;
which is why he throws me an error that join
is not identified: Method join does not exist.
Someone knows what I can do in this case, using eloquent.
JSON as it should be:
Current:
data: [
{
id: 1,
titulo: "Programador Android Jr.",
empresa: 1,
...
}]
As it should be:
data: [
{
id: 1,
titulo: "Programador Android Jr.",
empresa: "Empresa numero 1",
...
}]