-
app/Rules/ValidLicense.php
Open in GitHubuse Illuminate\Contracts\Validation\Rule; use Illuminate\Support\Facades\Http; class ValidLicense implements Rule { public function passes($attribute, $value) { return config('app.cloud') || $this->checkLicense($value); } protected function checkLicense(string $license): bool { if (app()->environment('local')) { return true; } return Http::get("https://archboard.io/verify/{$license}") ->json('valid'); } public function message() { return 'The validation error message.'; } }
-
app/Forms/Traits/ValidatesTenantFields.php
Open in GitHubuse App\Models\Tenant; use App\Rules\ValidLicense; use Illuminate\Validation\Rule; trait ValidatesTenantFields { public function licenseRules(Tenant $tenant): array { return [ 'required', 'uuid', new ValidLicense(), Rule::unique('tenants', 'license')->ignoreModel($tenant), ]; } // ... }