diff --git a/app/Enum/NGOType.php b/app/Enum/NGOType.php new file mode 100644 index 0000000..354deed --- /dev/null +++ b/app/Enum/NGOType.php @@ -0,0 +1,25 @@ +label(__('organisation.field.type')) ->options(OrganisationType::options()) ->enum(OrganisationType::class) + ->required() + ->reactive(), + + Select::make('ngo_type') + ->label(__('organisation.field.ngo_type')) + ->visible(fn (callable $get) => OrganisationType::ngo->is($get('type'))) + ->options(NGOType::options()) + ->enum(NGOType::class) ->required(), TextInput::make('year') diff --git a/app/Filament/Resources/OrganisationResource/Pages/ListOrganisations.php b/app/Filament/Resources/OrganisationResource/Pages/ListOrganisations.php index 00f96fd..946e666 100644 --- a/app/Filament/Resources/OrganisationResource/Pages/ListOrganisations.php +++ b/app/Filament/Resources/OrganisationResource/Pages/ListOrganisations.php @@ -4,6 +4,7 @@ namespace App\Filament\Resources\OrganisationResource\Pages; +use App\Enum\NGOType; use App\Enum\OrganisationType; use App\Filament\Forms\Components\Location; use App\Filament\Resources\OrganisationResource; @@ -65,6 +66,15 @@ protected function getActions(): array ->required() ->options(OrganisationType::options()) ->enum(OrganisationType::class) + ->reactive() + ->inlineLabel(), + + Select::make('ngo_type') + ->label(__('organisation.field.ngo_type')) + ->required() + ->visible(fn (callable $get) => OrganisationType::ngo->is($get('type'))) + ->options(NGOType::options()) + ->enum(NGOType::class) ->inlineLabel(), Location::make() diff --git a/app/Filament/Resources/ProfileResource/Concerns/ResolvesRecord.php b/app/Filament/Resources/ProfileResource/Concerns/ResolvesRecord.php index cc02c6f..8ee2194 100644 --- a/app/Filament/Resources/ProfileResource/Concerns/ResolvesRecord.php +++ b/app/Filament/Resources/ProfileResource/Concerns/ResolvesRecord.php @@ -10,6 +10,8 @@ public function mount($record = null): void { $this->record = auth()->user()->organisation; + abort_unless($this->record, 404); + $this->fillForm(); } } diff --git a/app/Models/Organisation.php b/app/Models/Organisation.php index eead17e..478ef80 100644 --- a/app/Models/Organisation.php +++ b/app/Models/Organisation.php @@ -7,6 +7,7 @@ use App\Concerns\HasLocation; use App\Concerns\LimitsVisibility; use App\Enum\DocumentType; +use App\Enum\NGOType; use App\Enum\OrganisationAreaType; use App\Enum\OrganisationStatus; use App\Enum\OrganisationType; @@ -51,6 +52,7 @@ public function registerMediaConversions(Media $media = null): void 'name', 'alias', 'type', + 'ngo_type', 'status', 'email', 'phone', @@ -70,6 +72,7 @@ public function registerMediaConversions(Media $media = null): void protected $casts = [ 'areas' => AsEnumCollection::class . ':' . OrganisationAreaType::class, 'type' => OrganisationType::class, + 'ngo_type' => NGOType::class, 'status' => OrganisationStatus::class, 'contact_person' => 'array', 'other_information' => AsCollection::class, diff --git a/database/factories/OrganisationFactory.php b/database/factories/OrganisationFactory.php index 14aec82..fc9d246 100644 --- a/database/factories/OrganisationFactory.php +++ b/database/factories/OrganisationFactory.php @@ -4,6 +4,7 @@ namespace Database\Factories; +use App\Enum\NGOType; use App\Enum\OrganisationAreaType; use App\Enum\OrganisationStatus; use App\Enum\OrganisationType; @@ -40,11 +41,15 @@ public function definition() $city = City::query()->inRandomOrder()->first(); $name = fake()->company(); + $type = fake()->randomElement(OrganisationType::values()); return [ 'name' => $name, 'alias' => Str::slug($name), - 'type' => fake()->randomElement(OrganisationType::values()), + 'type' => $type, + 'ngo_type' => OrganisationType::ngo->is($type) + ? fake()->randomElement(NGOType::values()) + : null, 'status' => fake()->randomElement(OrganisationStatus::values()), 'email' => fake()->unique()->safeEmail(), 'phone' => fake()->phoneNumber(), diff --git a/database/migrations/2014_10_11_002425_create_organisations_table.php b/database/migrations/2014_10_11_002425_create_organisations_table.php index d7a6d69..b98a7d0 100644 --- a/database/migrations/2014_10_11_002425_create_organisations_table.php +++ b/database/migrations/2014_10_11_002425_create_organisations_table.php @@ -2,9 +2,6 @@ declare(strict_types=1); -use App\Enum\OrganisationAreaType; -use App\Enum\OrganisationStatus; -use App\Enum\OrganisationType; use App\Models\City; use App\Models\County; use Illuminate\Database\Migrations\Migration; @@ -24,8 +21,9 @@ public function up() $table->id(); $table->string('name'); $table->string('alias')->nullable(); - $table->enum('type', OrganisationType::values()); - $table->enum('status', OrganisationStatus::values())->default('inactive'); + $table->string('type'); + $table->string('ngo_type')->nullable(); + $table->string('status')->default('inactive'); $table->string('email'); $table->string('phone'); $table->year('year')->nullable(); @@ -37,7 +35,7 @@ public function up() $table->text('description')->nullable(); $table->json('contact_person')->nullable(); $table->json('other_information')->nullable(); - $table->enum('type_of_area', OrganisationAreaType::values()); + $table->string('type_of_area')->nullable(); $table->json('areas')->nullable(); $table->boolean('has_branches')->default(false); $table->boolean('social_services_accreditation')->default(false); @@ -45,14 +43,4 @@ public function up() $table->timestamps(); }); } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('organisations'); - } }; diff --git a/database/migrations/2014_10_12_100000_create_password_resets_table.php b/database/migrations/2014_10_12_100000_create_password_resets_table.php index 793bfdb..9a64931 100644 --- a/database/migrations/2014_10_12_100000_create_password_resets_table.php +++ b/database/migrations/2014_10_12_100000_create_password_resets_table.php @@ -21,14 +21,4 @@ public function up() $table->timestamp('created_at')->nullable(); }); } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('password_resets'); - } }; diff --git a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php index 7c0cca6..a573ee2 100644 --- a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php +++ b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php @@ -25,14 +25,4 @@ public function up() $table->timestamp('failed_at')->useCurrent(); }); } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('failed_jobs'); - } }; diff --git a/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php b/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php index 9d9cd04..46d62c0 100644 --- a/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php +++ b/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php @@ -26,14 +26,4 @@ public function up() $table->timestamps(); }); } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('personal_access_tokens'); - } }; diff --git a/database/migrations/2023_01_27_143305_create_documents_table.php b/database/migrations/2023_01_27_143305_create_documents_table.php index 83feca7..409a9be 100644 --- a/database/migrations/2023_01_27_143305_create_documents_table.php +++ b/database/migrations/2023_01_27_143305_create_documents_table.php @@ -26,14 +26,4 @@ public function up() $table->foreignIdFor(Organisation::class)->constrained()->cascadeOnDelete(); }); } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('documents'); - } }; diff --git a/database/migrations/2023_05_04_014725_create_city_organisation_table.php b/database/migrations/2023_05_04_014725_create_city_organisation_table.php index 18acf4c..b0dcca0 100644 --- a/database/migrations/2023_05_04_014725_create_city_organisation_table.php +++ b/database/migrations/2023_05_04_014725_create_city_organisation_table.php @@ -2,6 +2,8 @@ declare(strict_types=1); +use App\Models\City; +use App\Models\Organisation; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -17,19 +19,9 @@ public function up() { Schema::create('city_organisation', function (Blueprint $table) { $table->id(); - $table->foreignIdFor(\App\Models\Organisation::class)->constrained()->cascadeOnDelete(); - $table->foreignIdFor(\App\Models\City::class)->constrained()->cascadeOnDelete(); + $table->foreignIdFor(Organisation::class)->constrained()->cascadeOnDelete(); + $table->foreignIdFor(City::class)->constrained()->cascadeOnDelete(); $table->timestamps(); }); } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('risk_categories'); - } }; diff --git a/database/migrations/2023_05_04_014725_create_organisation_risk_category_table.php b/database/migrations/2023_05_04_014725_create_organisation_risk_category_table.php index 024ead3..9a446fe 100644 --- a/database/migrations/2023_05_04_014725_create_organisation_risk_category_table.php +++ b/database/migrations/2023_05_04_014725_create_organisation_risk_category_table.php @@ -2,6 +2,8 @@ declare(strict_types=1); +use App\Models\Organisation; +use App\Models\Organisation\RiskCategory; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -17,19 +19,9 @@ public function up() { Schema::create('organisation_risk_category', function (Blueprint $table) { $table->id(); - $table->foreignIdFor(\App\Models\Organisation::class)->constrained()->cascadeOnDelete(); - $table->foreignIdFor(\App\Models\Organisation\RiskCategory::class)->constrained()->cascadeOnDelete(); + $table->foreignIdFor(Organisation::class)->constrained()->cascadeOnDelete(); + $table->foreignIdFor(RiskCategory::class)->constrained()->cascadeOnDelete(); $table->timestamps(); }); } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('risk_categories'); - } }; diff --git a/database/migrations/2023_05_04_023519_create_organisation_resource_type_table.php b/database/migrations/2023_05_04_023519_create_organisation_resource_type_table.php index ec2ba55..e844c66 100644 --- a/database/migrations/2023_05_04_023519_create_organisation_resource_type_table.php +++ b/database/migrations/2023_05_04_023519_create_organisation_resource_type_table.php @@ -2,6 +2,8 @@ declare(strict_types=1); +use App\Models\Organisation; +use App\Models\Organisation\ResourceType; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -17,19 +19,9 @@ public function up() { Schema::create('organisation_resource_type', function (Blueprint $table) { $table->id(); - $table->foreignIdFor(\App\Models\Organisation::class)->constrained()->cascadeOnDelete(); - $table->foreignIdFor(\App\Models\Organisation\ResourceType::class)->constrained()->cascadeOnDelete(); + $table->foreignIdFor(Organisation::class)->constrained()->cascadeOnDelete(); + $table->foreignIdFor(ResourceType::class)->constrained()->cascadeOnDelete(); $table->timestamps(); }); } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('resource_types'); - } }; diff --git a/database/migrations/2023_10_04_151611_add_two_factor_columns_to_table.php b/database/migrations/2023_10_04_151611_add_two_factor_columns_to_table.php index 2bbd972..4b5c4a4 100644 --- a/database/migrations/2023_10_04_151611_add_two_factor_columns_to_table.php +++ b/database/migrations/2023_10_04_151611_add_two_factor_columns_to_table.php @@ -24,15 +24,4 @@ public function up() ->nullable(); }); } - - public function down() - { - Schema::table(config('filament-breezy.users_table'), function (Blueprint $table) { - $table->dropColumn([ - 'two_factor_secret', - 'two_factor_recovery_codes', - 'two_factor_confirmed_at', - ]); - }); - } }; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 4609327..04a4a57 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -49,7 +49,6 @@ public function run() 'first_name' => 'Coordonator', 'last_name' => $county->name, 'email' => Str::slug($county->name) . '@example.com', - 'county_id' => $county->id, ])->toArray() ) ->create(); diff --git a/lang/ro/organisation.php b/lang/ro/organisation.php index 319d077..ba0cdcc 100644 --- a/lang/ro/organisation.php +++ b/lang/ro/organisation.php @@ -17,6 +17,7 @@ 'name' => 'Denumire organizație', 'alias' => 'Alias organizație', 'type' => 'Tip organizație', + 'ngo_type' => 'Tipul ONG-ului', 'email_organisation' => 'Email de contact organizație', 'phone_organisation' => 'Telefon de contact organizație', 'year' => 'Anul înființării', @@ -52,10 +53,15 @@ 'inactive' => 'Activeaza', ], 'types' => [ - 'association' => 'Asociatie', - 'foundation' => 'Fundatie', - 'federation' => 'Federatie', - 'informal_group' => 'Grup informal', + 'ngo' => 'ONG', + 'private' => 'Entitate privată', + 'public' => 'Instituție publică', + 'academic' => 'Mediu academic', + ], + 'ngo_types' => [ + 'association' => 'Asociație', + 'foundation' => 'Fundație', + 'federation' => 'Federație', ], 'area' => 'Organizația își desfășoară activitatea pe plan:', 'area_of_activity' => [