first()); } public static function isMethod(?ShippingMethod $method): bool { return self::isDriver($method?->driver); } /** * A shipping driver key (a method's `driver`, a shipment's `carrier`) * that resolves to Box Now. getSupportedDrivers() rather than * Shipping::driver(), which throws for a key no longer registered. */ public static function isDriver(?string $driver): bool { return $driver !== null && Shipping::getSupportedDrivers()->get($driver) instanceof BoxNowRateDriver; } /** * Codes of every Box Now shipping method — for marking options in bulk. * * @return array */ public static function codes(): array { return ShippingMethod::all() ->filter(fn (ShippingMethod $method) => self::isMethod($method)) ->pluck('code') ->values() ->all(); } }