<?php

declare(strict_types=1);

namespace App\Contracts;

/**
 * A record that belongs to exactly one marketplace account.
 *
 * Implemented by every owner-scoped resource -- domains, listings, offers,
 * orders, payouts -- so authorization can be decided uniformly instead of each
 * policy re-deriving "is this yours" from a different column name.
 *
 * The interface returns the owner's primary key rather than the User model, so
 * an ownership check never triggers a relation load. Authorization runs on every
 * request; it must not cost a query per check.
 */
interface OwnedByUser
{
    /**
     * The primary key of the account that owns this record.
     *
     * Null only for a record whose owner has not been assigned yet, which must
     * be treated as "nobody owns it" rather than "everybody does".
     */
    public function ownerId(): ?int;
}
