Good morning,
I have the following relationship in the database:
class Address extends Model
{
....
public function addressestimate()
{
return $this->hasMany('\App\Models\AddressEstimate', 'addressesid', 'id');
}
When retrieving the data, I output you as follows:
public function show($id, $delegatesid)
{
$data = Address::with('files')->with('addressestimate')->with('salutation')->with('country')->where('id', $id)->where('delegatesid', $delegatesid)->get();
return response()->json($data);
}
When I enter the API call accordingly in the browser, all the data is displayed to me, including the 3 elements in the addressestimate. If I make the call with Vue, everything is shown in the console except addressestimate which is always empty. I have this with 3 different browsers and I don't understand the problem.
All other relations will also display your content.
Here is the call in Vue
this.$http.get('/addresses/' + this.$route.params.salesleadid + '/delegates/' + userInfo.user.delegatesid)
.then(function (response) {
console.log(response)
And this is the route
Route::get('/addresses/{id}/delegates/{delegatesid}', [AddressesController::class, 'show'])->where('id', '[0-9]+')->where('delegatesid', '[0-9]+');