feat: add bylaw management features including documents, legal authorities, subject categories, and nodes
This commit is contained in:
@@ -12,7 +12,7 @@ return new class extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('versions', function (Blueprint $table) {
|
||||
$table->enum('type',['web','ios','android'])->after('code')->default('web');
|
||||
$table->enum('type', ['web', 'ios', 'android'])->after('code')->default('web');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -19,12 +19,10 @@ return new class extends Migration
|
||||
$table->foreignId('division_id')->after('number')->nullable();
|
||||
});
|
||||
|
||||
|
||||
Schema::table('parts', function (Blueprint $table) {
|
||||
$table->foreignId('division_id')->after('number')->nullable();
|
||||
});
|
||||
|
||||
|
||||
Schema::table('gates', function (Blueprint $table) {
|
||||
$table->foreignId('division_id')->after('number')->nullable();
|
||||
});
|
||||
|
||||
@@ -11,8 +11,7 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if(!Schema::hasTable('like_sections'))
|
||||
{
|
||||
if (! Schema::hasTable('like_sections')) {
|
||||
Schema::create('like_sections', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id');
|
||||
|
||||
@@ -11,16 +11,15 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if(!Schema::hasTable('like_art'))
|
||||
{
|
||||
if (! Schema::hasTable('like_art')) {
|
||||
Schema::create('like_art', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('art_id');
|
||||
$table->foreignId('user_id');
|
||||
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if (!Schema::hasTable('notes')) {
|
||||
if (! Schema::hasTable('notes')) {
|
||||
|
||||
Schema::create('notes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
@@ -15,7 +15,7 @@ return new class extends Migration
|
||||
$table->id();
|
||||
$table->foreignId('user_id');
|
||||
$table->BigInteger('price');
|
||||
$table->enum('status' , ['unpaid' , 'paid' , 'canceled']);
|
||||
$table->enum('status', ['unpaid', 'paid', 'canceled']);
|
||||
$table->string('transaction_id');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ return new class extends Migration
|
||||
Schema::create('categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->enum('type',['hagigi','kifari']);
|
||||
$table->enum('type', ['hagigi', 'kifari']);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ return new class extends Migration
|
||||
$table->id();
|
||||
$table->foreignId('user_id');
|
||||
$table->foreignId('subscribe_plan_id');
|
||||
$table->timestamp('expired_at');
|
||||
$table->timestamp('expired_at');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ return new class extends Migration
|
||||
{
|
||||
Schema::table('subscribe_plans', function (Blueprint $table) {
|
||||
$table->string('type')->nullable();
|
||||
$table->string('transaction')->nullable();
|
||||
$table->string('transaction')->nullable();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('user_subscribers', function (Blueprint $table) {
|
||||
Schema::table('user_subscribers', function (Blueprint $table) {
|
||||
$table->string('subscription_id')->nullable();
|
||||
$table->string('purchase_token')->nullable();
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@ return new class extends Migration
|
||||
$table->foreignId('art_id')->constrained('art')->onDelete('cascade');
|
||||
$table->foreignId('judicial_precedent_id')->constrained('judicial_precedents')->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
|
||||
|
||||
$table->unique(['art_id', 'judicial_precedent_id']);
|
||||
});
|
||||
}
|
||||
|
||||
128
database/migrations/2026_06_26_000001_create_bylaw_tables.php
Normal file
128
database/migrations/2026_06_26_000001_create_bylaw_tables.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
DB::statement('SET FOREIGN_KEY_CHECKS=0');
|
||||
|
||||
Schema::create('bylaw_legal_authorities', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name')->unique();
|
||||
$table->enum('authority_type', ['executive', 'judicial', 'legislative', 'administrative', 'other']);
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('bylaw_subject_categories', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('parent_id')->nullable();
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
$table->integer('sort_order')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('parent_id')->references('id')->on('bylaw_subject_categories')->nullOnDelete();
|
||||
});
|
||||
|
||||
Schema::create('bylaw_documents', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('title', 1000);
|
||||
$table->unsignedInteger('category_id')->nullable();
|
||||
$table->unsignedInteger('approval_authority_id')->nullable();
|
||||
$table->date('approval_date')->nullable();
|
||||
$table->unsignedInteger('promulgation_authority_id')->nullable();
|
||||
$table->date('promulgation_date')->nullable();
|
||||
$table->string('promulgation_number', 100)->nullable();
|
||||
$table->string('official_gazette_number', 100)->nullable();
|
||||
$table->date('official_gazette_date')->nullable();
|
||||
$table->date('execution_date')->nullable();
|
||||
$table->enum('bylaw_type', ['executive', 'delegated', 'independent']);
|
||||
$table->enum('global_status', ['valid', 'explicitly_repealed', 'implicitly_repealed', 'annulled', 'expired', 'draft'])->default('valid');
|
||||
$table->string('pdf_file_path', 500)->nullable();
|
||||
$table->boolean('is_published')->default(true);
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('category_id')->references('id')->on('bylaw_subject_categories')->nullOnDelete();
|
||||
$table->foreign('approval_authority_id')->references('id')->on('bylaw_legal_authorities')->nullOnDelete();
|
||||
$table->foreign('promulgation_authority_id')->references('id')->on('bylaw_legal_authorities')->nullOnDelete();
|
||||
$table->index(['approval_date', 'promulgation_date'], 'idx_bylaw_dates');
|
||||
$table->index('global_status', 'idx_bylaw_status');
|
||||
});
|
||||
|
||||
Schema::create('bylaw_node_types', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name', 50)->unique();
|
||||
$table->integer('hierarchy_level');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('bylaw_nodes', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->unsignedBigInteger('document_id');
|
||||
$table->unsignedBigInteger('parent_id')->nullable();
|
||||
$table->unsignedInteger('node_type_id');
|
||||
$table->string('node_identifier', 50)->nullable();
|
||||
$table->string('title', 500)->nullable();
|
||||
$table->longText('node_content')->nullable();
|
||||
$table->integer('sort_order')->default(0);
|
||||
$table->date('valid_from')->nullable();
|
||||
$table->date('valid_to')->nullable();
|
||||
$table->enum('node_status', ['valid', 'repealed', 'annulled', 'amended', 'suspended'])->default('valid');
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('document_id')->references('id')->on('bylaw_documents')->cascadeOnDelete();
|
||||
$table->foreign('parent_id')->references('id')->on('bylaw_nodes')->cascadeOnDelete();
|
||||
$table->foreign('node_type_id')->references('id')->on('bylaw_node_types')->restrictOnDelete();
|
||||
$table->index(['document_id', 'parent_id'], 'idx_node_tree');
|
||||
$table->index(['node_status', 'valid_from', 'valid_to'], 'idx_node_temporal');
|
||||
});
|
||||
|
||||
Schema::table('bylaw_nodes', function (Blueprint $table) {
|
||||
$table->fullText(['node_content', 'title'], 'ft_idx_content');
|
||||
});
|
||||
|
||||
Schema::create('bylaw_codification_links', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->enum('source_entity_type', ['bylaw_node', 'bylaw_doc', 'law_doc', 'court_verdict', 'advisory_opinion']);
|
||||
$table->unsignedBigInteger('source_entity_id');
|
||||
$table->enum('target_entity_type', ['bylaw_node', 'bylaw_doc', 'law_doc', 'court_verdict', 'advisory_opinion']);
|
||||
$table->unsignedBigInteger('target_entity_id');
|
||||
$table->enum('link_type', ['repeals_explicitly', 'repeals_implicitly', 'annuls_entirely', 'annuls_partially', 'amends', 'adds_to', 'interprets', 'is_executive_bylaw_of']);
|
||||
$table->date('effective_date')->nullable();
|
||||
$table->text('justification')->nullable();
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
|
||||
$table->unique(['source_entity_type', 'source_entity_id', 'target_entity_type', 'target_entity_id', 'link_type'], 'idx_unique_link');
|
||||
$table->index(['target_entity_type', 'target_entity_id'], 'idx_target_search');
|
||||
});
|
||||
|
||||
DB::table('bylaw_node_types')->insertOrIgnore([
|
||||
['id' => 1, 'name' => 'متن کامل آییننامه', 'hierarchy_level' => 1, 'created_at' => now(), 'updated_at' => now()],
|
||||
]);
|
||||
|
||||
DB::table('bylaw_subject_categories')->insertOrIgnore([
|
||||
['id' => 9, 'name' => 'آیین نامه ها', 'slug' => 'bylaws', 'sort_order' => 0, 'created_at' => now(), 'updated_at' => now()],
|
||||
]);
|
||||
|
||||
DB::statement('SET FOREIGN_KEY_CHECKS=1');
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
DB::statement('SET FOREIGN_KEY_CHECKS=0');
|
||||
Schema::dropIfExists('bylaw_codification_links');
|
||||
Schema::dropIfExists('bylaw_nodes');
|
||||
Schema::dropIfExists('bylaw_node_types');
|
||||
Schema::dropIfExists('bylaw_documents');
|
||||
Schema::dropIfExists('bylaw_subject_categories');
|
||||
Schema::dropIfExists('bylaw_legal_authorities');
|
||||
DB::statement('SET FOREIGN_KEY_CHECKS=1');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user