-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
I believe that #1653 introduced an undesirable bug when using a Model with no key as the target for a gate check.
It presents itself as The attribute [id] either does not exist or was not retrieved for model [App\Models\ModelName]. and took me quite a while to realise it was a problem with debug bar, and not with my code, as the vendor trace is hidden by default.
I have a model Attendance which extends from Illuminate\Database\Eloquent\Relations\Pivot. Instances are unique by the foreignKey and relatedKey. AsPivot handles this internally and makes an isset check for any primary key before setting keys for query manually.
In the case of a Pivot model, you could use the foreign and related keys in the description. But I can imagine a case where a model has been fetched without its id which would still break this feature, so it may be wise to include an isset check of your own and fall back to no description?