devondahon's avatar

How to get the model id from BelongsTo relationship?

I tried $this->id but it returns nothing with artisan tinker:

class Part extends Model
{
    public function inv(): BelongsTo
    {
        echo "foo\n";
        echo $this->id . "\n";
        return $this->belongsTo(
            Inv::class,
            'surv_id',
            'surv_id'
        );
    }
}
0 likes
2 replies

Please or to participate in this conversation.