Description
I'm developing a new API on Lumen and renaming the columns of the legacy database.
I have two tables, Images and Variants, Images has many Variants.
- Variants is the mapped name of the table usu_t075varest
- Images is the mapped name of the table usu_t075desest
Mapped this relation as the Lumen docs suggest:
Image.php
public function variants() {
return $this->hasMany(Variant::class, 'usu_coddes','usu_coddes');
}
- usu_coddes is the foreign key on Variants table.
- usu_coddes is the primary key on Images table.
Calling the the route \api\images\SR16105G13
with no authentication:
public function read($id) {
$image = Image::where('usu_coddes', $id)
->with('variants')
->first();
if ($image === null)
return response(null, 404);
return response()->json($image);
}
The PHP interpreter never goes beyond the with('variants')
function, i did some step by step debugging with Zend debugger and saw that in the function callHook
on Sofa\Hookable\Builder
it calls the callParent
function with the first argument "whereIn"
so it will call the parent whereIn
on Eloquent\Builder
but that function doesn't exists there, so PHP reverts the call back to whereIn
on Sofa\Hookable\Builder
that calls callHook
and so on, until call stack is exceeded for Apache and it reboots killing the connection.
I'm not very familiar with Lumen Eloquent structure to make any modification to solve this, anyone could give me a hand or commit the solution?