Skip to content

Commit

Permalink
feat: update organization types (#115)
Browse files Browse the repository at this point in the history
* feat: add ngo type field

* cleanup
  • Loading branch information
andreiio authored Oct 19, 2023
1 parent c1140ad commit e73d0bc
Show file tree
Hide file tree
Showing 18 changed files with 85 additions and 113 deletions.
25 changes: 25 additions & 0 deletions app/Enum/NGOType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace App\Enum;

use App\Concerns\Enums\Arrayable;
use App\Concerns\Enums\Comparable;
use App\Concerns\Enums\HasLabel;

enum NGOType: string
{
use Arrayable;
use Comparable;
use HasLabel;

case association = 'association';
case foundation = 'foundation';
case federation = 'federation';

protected function labelKeyPrefix(): ?string
{
return 'organisation.field.ngo_types';
}
}
8 changes: 4 additions & 4 deletions app/Enum/OrganisationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ enum OrganisationType: string
use Comparable;
use HasLabel;

case association = 'association';
case foundation = 'foundation';
case federation = 'federation';
case informalGroup = 'informal_group';
case ngo = 'ngo';
case private = 'private';
case public = 'public';
case academic = 'academic';

protected function labelKeyPrefix(): ?string
{
Expand Down
9 changes: 9 additions & 0 deletions app/Filament/Resources/OrganisationResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Filament\Resources;

use App\Enum\NGOType;
use App\Enum\OrganisationAreaType;
use App\Enum\OrganisationType;
use App\Filament\Forms\Components\Location;
Expand Down Expand Up @@ -78,6 +79,14 @@ public static function form(Form $form): Form
->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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public function mount($record = null): void
{
$this->record = auth()->user()->organisation;

abort_unless($this->record, 404);

$this->fillForm();
}
}
3 changes: 3 additions & 0 deletions app/Models/Organisation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -51,6 +52,7 @@ public function registerMediaConversions(Media $media = null): void
'name',
'alias',
'type',
'ngo_type',
'status',
'email',
'phone',
Expand All @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion database/factories/OrganisationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Database\Factories;

use App\Enum\NGOType;
use App\Enum\OrganisationAreaType;
use App\Enum\OrganisationStatus;
use App\Enum\OrganisationType;
Expand Down Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -37,22 +35,12 @@ 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);
$table->softDeletes();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('organisations');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,4 @@ public function up()
$table->timestamp('created_at')->nullable();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
};
10 changes: 0 additions & 10 deletions database/migrations/2019_08_19_000000_create_failed_jobs_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,4 @@ public function up()
$table->timestamp('failed_at')->useCurrent();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('failed_jobs');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,4 @@ public function up()
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('personal_access_tokens');
}
};
10 changes: 0 additions & 10 deletions database/migrations/2023_01_27_143305_create_documents_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,4 @@ public function up()
$table->foreignIdFor(Organisation::class)->constrained()->cascadeOnDelete();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('documents');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);
});
}
};
1 change: 0 additions & 1 deletion database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
14 changes: 10 additions & 4 deletions lang/ro/organisation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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' => [
Expand Down

0 comments on commit e73d0bc

Please sign in to comment.