, key: string, permission: string}> */ public const TYPES = [ 'services' => ['model' => Service::class, 'key' => 'id', 'permission' => 'customer.edit'], 'customers' => ['model' => Customer::class, 'key' => 'uuid', 'permission' => 'customer.edit'], 'orders' => ['model' => Order::class, 'key' => 'id', 'permission' => 'order.edit'], 'invoices' => ['model' => Invoice::class, 'key' => 'id', 'permission' => 'invoice.edit'], ]; public static function find(string $type, string $key): Model { $definition = self::TYPES[$type]; return $definition['model']::query()->where($definition['key'], $key)->firstOrFail(); } }