"name"]); } public static function getOptions(): array { $options = []; foreach(self::getAll() as $supplier) { $options[$supplier->id] = $supplier->name; } return $options; } // Object methods /** * @return Address * @throws \Exception */ public function getAddress(): Address { $address = Address::get($this->address_id); return $address ?: new Address(); } public function getSlug(): string { return Util::slug("$this->name $this->id"); } public function getUrl(): string { return sprintf("/suppliers/%s", $this->getSlug()); } /** * @return Product[] */ public function getProducts(array $nvp = []): array { $nvp = array_merge($nvp, [ "supplier_id" => $this->id, "dts_deleted" => null ]); return Product::query($nvp, ["sort" => "name"]); } }