Hello,
I have a very strange problem with an app on which I work and which has been started by another dev.
Here are the tables.
brands : id, name
bicycles : id, name, brand // the brand is a string in the database
quotation : id, bicycle_id
And the quotation model with the relationship.
public function bicycle()
{
return $this->belongsTo('App\Models\Bicycle');
}
But there is no relationship with the Brand model, neither with the Bicycle nor with the Quotation models.
All worked fine until an update of the one brand (update imported from an Excel file). When I list the quotations, I use $quotation->bicycle to access the bicycle from the quotation. All is ok except for the bicycles with the brand which has been updated.
In the database all is ok, the foreign key is ok in the quotation line, but when I try to access the bicycle from the quotation in Laravel, I have this error.
Trying to get property 'brand' of non-object
I have tested : $quotation->bicycle is null.
That's very strange because all datas are ok in the database. I have done php artisan to clear and cache the config, the routes, the views, ... but no result to solve the problem.
So my question is : do you have already encountered such a problem and what could be the cause of the problem ?
Thanks for your help.
Vincent