structure and style updates
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
use Modules\Countries\Support\ModuleInfo;
|
||||
|
||||
if (! function_exists('countries_feature_enabled')) {
|
||||
|
||||
@@ -57,7 +57,7 @@ class CountriesController extends Controller
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
return view('countries::create', ['country' => new Country()]);
|
||||
return view('countries::create', ['country' => new Country]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +112,6 @@ class CountriesController extends Controller
|
||||
/**
|
||||
* Build the database payload from validated request data.
|
||||
*
|
||||
* @param StoreCountryRequest|UpdateCountryRequest $request
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function payload(StoreCountryRequest|UpdateCountryRequest $request): array
|
||||
|
||||
@@ -16,7 +16,6 @@ class StoreCountryRequest extends FormRequest
|
||||
return (bool) $this->user()?->isMpbaPlatformAdmin();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Normalise ISO code inputs before validation.
|
||||
*/
|
||||
|
||||
@@ -16,7 +16,6 @@ class UpdateCountryRequest extends FormRequest
|
||||
return (bool) $this->user()?->isMpbaPlatformAdmin();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Normalise ISO code inputs before validation.
|
||||
*/
|
||||
|
||||
@@ -125,6 +125,7 @@ class CountriesServiceProvider extends ServiceProvider
|
||||
|
||||
if (is_dir($publishedPath)) {
|
||||
$this->loadTranslationsFrom($publishedPath, ModuleInfo::nameLower());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,7 @@ use Illuminate\Contracts\Validation\ValidationRule;
|
||||
|
||||
class ValidCountryCode implements ValidationRule
|
||||
{
|
||||
public function __construct(private readonly bool $activeOnly = true)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly bool $activeOnly = true) {}
|
||||
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
|
||||
@@ -11,13 +11,13 @@ class ValidIso3166CountryCode implements ValidationRule
|
||||
public function __construct(
|
||||
private readonly bool $activeOnly = true,
|
||||
private readonly string $format = 'alpha2',
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
if (! is_string($value) && ! is_int($value)) {
|
||||
$fail('The :attribute must be a valid ISO 3166 country code.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,14 +8,13 @@ use Modules\Countries\Models\CountrySubdivision;
|
||||
|
||||
class ValidIso3166SubdivisionCode implements ValidationRule
|
||||
{
|
||||
public function __construct(private readonly bool $activeOnly = true)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly bool $activeOnly = true) {}
|
||||
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
if (! is_string($value) || ! preg_match('/^[A-Z]{2}-[A-Z0-9]{1,6}$/', strtoupper($value))) {
|
||||
$fail('The :attribute must be a valid ISO 3166-2 subdivision code.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,15 @@ use InvalidArgumentException;
|
||||
final class Iso3166
|
||||
{
|
||||
public const STATUS_OFFICIAL = 'official';
|
||||
|
||||
public const STATUS_RESERVED = 'reserved';
|
||||
|
||||
public const STATUS_TRANSITIONAL = 'transitional';
|
||||
|
||||
public const STATUS_DELETED = 'deleted';
|
||||
|
||||
public const STATUS_USER_ASSIGNED = 'user_assigned';
|
||||
|
||||
public const STATUS_EXCEPTIONALLY_RESERVED = 'exceptionally_reserved';
|
||||
|
||||
/** @return list<string> */
|
||||
|
||||
@@ -4,11 +4,10 @@ namespace Modules\Countries\Support;
|
||||
|
||||
class ModuleInfo
|
||||
{
|
||||
protected static string $moduleName = 'Countries';
|
||||
protected static string $moduleName = 'Countries';
|
||||
|
||||
/**
|
||||
* defines the Module Name
|
||||
* @return string
|
||||
*/
|
||||
public static function name(): string
|
||||
{
|
||||
@@ -17,7 +16,6 @@ class ModuleInfo
|
||||
|
||||
/**
|
||||
* define the lowercase version
|
||||
* @return string
|
||||
*/
|
||||
public static function nameLower(): string
|
||||
{
|
||||
|
||||
@@ -4,8 +4,6 @@ namespace Modules\Countries\Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Modules\Countries\Database\Seeders\CountriesDatabaseSeeder;
|
||||
use Modules\Countries\Models\Country;
|
||||
use Modules\Countries\Models\CountrySubdivision;
|
||||
use Modules\Countries\Rules\ValidIso3166CountryCode;
|
||||
use Modules\Countries\Rules\ValidIso3166SubdivisionCode;
|
||||
use Tests\TestCase;
|
||||
|
||||
Reference in New Issue
Block a user