timtom
1 month ago

Undefined property: HasMany::$id

Posted 1 month ago by timtom

Hello,

I got a problem with foreign relations and eloquent, i would like to retrieve id from this :

$invoice->payments()->latest('date')->first()->id

And i got this error :

ErrorException: Undefined property: Illuminate\Database\Eloquent\Relations\HasMany::$id

It is strange because this is working for example : $invoice->payments()->sum('amount')

Someone already got this error ?

Please sign in or create an account to participate in this conversation.