Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}

- name: Run Laravel Pint
uses: aglipanci/laravel-pint-action@latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "filament/support" --no-interaction --no-update
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "filament/support:^3.3" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-progress --no-interaction

- name: Run test suite
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"php": "^8.2",
"bezhansalleh/filament-shield": "^3.3",
"datalinx/php-utils": "^2.5",
"eclipsephp/common": "dev-main",
"filament/filament": "^3.3",
"laravel/framework": "^11.0|^12.0",
"spatie/laravel-package-tools": "^1.19"
Expand Down
1 change: 1 addition & 0 deletions database/factories/CountryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function definition(): array
'num_code' => str_pad(fake()->numberBetween(1, 999), 3, '0', STR_PAD_LEFT),
'name' => fake()->country(),
'flag' => fake()->emoji(),
'region_id' => null,
];
}
}
60 changes: 60 additions & 0 deletions database/factories/RegionFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace Eclipse\World\Factories;

use Eclipse\World\Models\Region;
use Illuminate\Database\Eloquent\Factories\Factory;

class RegionFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Region::class;

/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'code' => strtoupper($this->faker->unique()->lexify('???')),
'name' => $this->faker->unique()->words(2, true),
'is_special' => false,
];
}

/**
* Set the region as special.
*
* @return $this
*/
public function special(): static
{
return $this->state(['is_special' => true]);
}

/**
* Set the region as geographical.
*
* @return $this
*/
public function geographical(): static
{
return $this->state(['is_special' => false]);
}

/**
* Set the region as a child of a parent region.
*
* @return $this
*/
public function withParent(Region $parent): static
{
return $this->state(['parent_id' => $parent->id]);
}
}
29 changes: 29 additions & 0 deletions database/migrations/2025_07_26_120000_create_regions_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up(): void
{
Schema::create('world_regions', function (Blueprint $table) {
$table->id();
$table->string('code')->nullable()->unique();
$table->unsignedBigInteger('parent_id')->nullable();
$table->boolean('is_special')->default(false);
$table->string('name');
$table->timestamps();
$table->softDeletes();

$table->foreign('parent_id')->references('id')->on('world_regions')->onDelete('cascade');
$table->index(['is_special', 'parent_id']);
});
}

public function down(): void
{
Schema::dropIfExists('world_regions');
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up(): void
{
Schema::table('world_countries', function (Blueprint $table) {
$table->unsignedBigInteger('region_id')->nullable()->after('flag');
$table->foreign('region_id')->references('id')->on('world_regions')->onDelete('set null');
$table->index('region_id');
});
}

public function down(): void
{
Schema::table('world_countries', function (Blueprint $table) {
$table->dropForeign(['region_id']);
$table->dropIndex(['region_id']);
$table->dropColumn('region_id');
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up(): void
{
Schema::create('world_country_in_special_region', function (Blueprint $table) {
$table->id();
$table->string('country_id', 2);
$table->unsignedBigInteger('region_id');
$table->date('start_date');
$table->date('end_date')->nullable();
$table->timestamps();

$table->foreign('country_id')->references('id')->on('world_countries')->onDelete('cascade');
$table->foreign('region_id')->references('id')->on('world_regions')->onDelete('cascade');

$table->unique(['country_id', 'region_id', 'start_date'], 'unique_country_region_start');
$table->index(['region_id', 'start_date', 'end_date'], 'idx_region_dates');
});
}

public function down(): void
{
Schema::dropIfExists('world_country_in_special_region');
}
};
32 changes: 32 additions & 0 deletions resources/lang/en/countries.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
'num_code' => [
'label' => 'Num. Code',
],
'region' => [
'label' => 'Region',
],
'special_regions' => [
'label' => 'Special Regions',
],
],

'actions' => [
Expand Down Expand Up @@ -67,6 +73,18 @@
'label' => 'Numeric code',
'helper' => 'Numeric code (ISO-3166)',
],
'region' => [
'label' => 'Geographical Region',
'helper' => 'The geographical region this country belongs to',
],
'special_regions' => [
'label' => 'Special Regions',
'helper' => 'Special regions this country belongs to (e.g., European Union)',
'add_button' => 'Add Special Region',
'region_label' => 'Region',
'start_date_label' => 'Start Date',
'end_date_label' => 'End Date',
],
],

'import' => [
Expand All @@ -86,4 +104,18 @@
'title' => 'Countries Import failed',
],
],

'filters' => [
'geographical_region' => [
'label' => 'Geographical Region',
],
'special_region' => [
'label' => 'Special Region',
],
],

'validation' => [
'duplicate_special_region_membership' => 'This country is already a member of :region.',
'unknown_region' => 'this region',
],
];
81 changes: 81 additions & 0 deletions resources/lang/en/regions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

return [
'nav_label' => 'Regions',
'breadcrumb' => 'Regions',
'plural' => 'Regions',

'form' => [
'name' => [
'label' => 'Name',
],
'code' => [
'label' => 'Code',
'helper' => 'Optional unique code for the region (e.g., EU, ASEAN)',
],
'parent' => [
'label' => 'Parent Region',
'helper' => 'Select a parent region to create a sub-region',
],
'is_special' => [
'label' => 'Special Region',
'helper' => 'Special regions are custom regions like EU or EEA that countries can join/leave',
],
],

'table' => [
'name' => [
'label' => 'Name',
],
'code' => [
'label' => 'Code',
],
'parent' => [
'label' => 'Parent Region',
],
'is_special' => [
'label' => 'Special',
],
'countries_count' => [
'label' => 'Countries',
],
'children_count' => [
'label' => 'Sub-regions',
],
],

'filters' => [
'type' => [
'label' => 'Type',
'geographical' => 'Geographical',
'special' => 'Special',
],
'parent' => [
'label' => 'Parent Region',
],
],

'actions' => [
'create' => [
'label' => 'New Region',
'heading' => 'Create Region',
],
'edit' => [
'label' => 'Edit',
'heading' => 'Edit Region',
],
'delete' => [
'label' => 'Delete',
'heading' => 'Delete Region',
],
'restore' => [
'label' => 'Restore',
'heading' => 'Restore Region',
],
'force_delete' => [
'label' => 'Force Delete',
'heading' => 'Force Delete Region',
'description' => 'Are you sure you want to permanently delete ":name"? This action cannot be undone.',
],
],
];
32 changes: 32 additions & 0 deletions resources/lang/hr/countries.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
'num_code' => [
'label' => 'Brojčana šifra',
],
'region' => [
'label' => 'Regija',
],
'special_regions' => [
'label' => 'Posebne regije',
],
],

'actions' => [
Expand Down Expand Up @@ -67,6 +73,18 @@
'label' => 'Brojčana šifra',
'helper' => 'Numerička oznaka (ISO-3166)',
],
'region' => [
'label' => 'Geografska regija',
'helper' => 'Geografska regija kojoj ova zemlja pripada',
],
'special_regions' => [
'label' => 'Posebne regije',
'helper' => 'Posebne regije kojima ova zemlja pripada (npr. Europska unija)',
'add_button' => 'Dodaj posebnu regiju',
'region_label' => 'Regija',
'start_date_label' => 'Datum početka',
'end_date_label' => 'Datum završetka',
],
],

'import' => [
Expand All @@ -86,4 +104,18 @@
'title' => 'Uvoz država neuspješan',
],
],

'filters' => [
'geographical_region' => [
'label' => 'Geografska regija',
],
'special_region' => [
'label' => 'Posebna regija',
],
],

'validation' => [
'duplicate_special_region_membership' => 'Ova država je već član regije :region.',
'unknown_region' => 'ove regije',
],
];
Loading