feat: add bylaw management features including documents, legal authorities, subject categories, and nodes

This commit is contained in:
2026-06-26 13:49:50 +03:30
parent 2e26bd229b
commit 9cf6957675
113 changed files with 1112 additions and 358 deletions

View File

@@ -48,7 +48,6 @@ class Book extends Model
return $this->hasMany(Branch::class);
}
public static function searchLimit($searchTerm)
{
return self::where('title', 'LIKE', "%{$searchTerm}%")->limit(3)->get();

View File

@@ -8,9 +8,8 @@ use Illuminate\Database\Eloquent\Model;
class Branch extends Model
{
use HasFactory;
protected $fillable = ['title', 'number', 'chapter_id', 'part_id', 'volum_id', 'law_id', 'book_id', 'section_id', 'gate_id','division_id'];
protected $fillable = ['title', 'number', 'chapter_id', 'part_id', 'volum_id', 'law_id', 'book_id', 'section_id', 'gate_id', 'division_id'];
public function art()
{
@@ -21,7 +20,7 @@ class Branch extends Model
{
return self::where('title', 'LIKE', "%{$searchTerm}%")->get();
}
public static function searchLimit($searchTerm)
{
return self::where('title', 'LIKE', "%{$searchTerm}%")->limit(3)->get();

View File

@@ -0,0 +1,14 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class BylawCodificationLink extends Model
{
protected $table = 'bylaw_codification_links';
public $timestamps = false;
protected $fillable = ['source_entity_type', 'source_entity_id', 'target_entity_type', 'target_entity_id', 'link_type', 'effective_date', 'justification', 'created_at'];
}

View File

@@ -0,0 +1,34 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class BylawDocument extends Model
{
protected $table = 'bylaw_documents';
protected $fillable = ['title', 'category_id', 'approval_authority_id', 'approval_date', 'promulgation_authority_id', 'promulgation_date', 'promulgation_number', 'official_gazette_number', 'official_gazette_date', 'execution_date', 'bylaw_type', 'global_status', 'pdf_file_path', 'is_published', 'description'];
protected $casts = ['is_published' => 'boolean'];
public function category()
{
return $this->belongsTo(BylawSubjectCategory::class, 'category_id');
}
public function approvalAuthority()
{
return $this->belongsTo(BylawLegalAuthority::class, 'approval_authority_id');
}
public function promulgationAuthority()
{
return $this->belongsTo(BylawLegalAuthority::class, 'promulgation_authority_id');
}
public function nodes()
{
return $this->hasMany(BylawNode::class, 'document_id');
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class BylawLegalAuthority extends Model
{
protected $table = 'bylaw_legal_authorities';
protected $fillable = ['name', 'authority_type', 'description'];
}

27
app/Models/BylawNode.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class BylawNode extends Model
{
protected $table = 'bylaw_nodes';
protected $fillable = ['document_id', 'parent_id', 'node_type_id', 'node_identifier', 'title', 'node_content', 'sort_order', 'valid_from', 'valid_to', 'node_status'];
public function document()
{
return $this->belongsTo(BylawDocument::class, 'document_id');
}
public function parent()
{
return $this->belongsTo(self::class, 'parent_id');
}
public function type()
{
return $this->belongsTo(BylawNodeType::class, 'node_type_id');
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class BylawNodeType extends Model
{
protected $table = 'bylaw_node_types';
protected $fillable = ['name', 'hierarchy_level'];
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class BylawSubjectCategory extends Model
{
protected $table = 'bylaw_subject_categories';
protected $fillable = ['parent_id', 'name', 'slug', 'sort_order'];
public function parent()
{
return $this->belongsTo(self::class, 'parent_id');
}
}

View File

@@ -11,22 +11,19 @@ class Category extends Model
protected $fillable = [
'name',
'type'
'type',
];
public function laws()
{
return $this->hasMany(Law::class);
}
public static function getType()
{
return [
'hagigi' => 'حقیقی',
'kifari' => 'کیفری'
'kifari' => 'کیفری',
];
}
}

View File

@@ -9,7 +9,7 @@ class Chapter extends Model
{
use HasFactory;
protected $fillable = ['title', 'number', 'section_id', 'book_id', 'volum_id', 'law_id','division_id'];
protected $fillable = ['title', 'number', 'section_id', 'book_id', 'volum_id', 'law_id', 'division_id'];
protected $hidden = ['created_at', 'updated_at'];
@@ -28,7 +28,6 @@ class Chapter extends Model
return $this->hasMany(Gate::class);
}
public function branch()
{
return $this->hasMany(Branch::class);

View File

@@ -11,7 +11,6 @@ class Division extends Model
protected $fillable = ['title', 'number', 'book_id', 'volum_id', 'law_id'];
public function sections()
{
return $this->hasMany(Section::class);
@@ -47,7 +46,6 @@ class Division extends Model
return $this->hasMany(Art::class);
}
public function gates()
{
return $this->hasMany(Gate::class);
@@ -67,5 +65,4 @@ class Division extends Model
{
return self::where('title', 'LIKE', "%{$searchTerm}%")->limit(3)->get();
}
}

View File

@@ -11,7 +11,7 @@ class Folder extends Model
protected $fillable = [
'user_id',
'name'
'name',
];
public function arts()

View File

@@ -11,11 +11,11 @@ class FolderArt extends Model
protected $fillable = [
'folder_id',
'art_id'
'art_id',
];
public function arts()
{
return $this->belongsTo(Art::class,'art_id');
return $this->belongsTo(Art::class, 'art_id');
}
}

View File

@@ -9,7 +9,7 @@ class Gate extends Model
{
use HasFactory;
protected $fillable = ['title', 'number', 'part_id', 'chapter_id', 'section_id', 'book_id', 'volum_id', 'law_id','division_id'];
protected $fillable = ['title', 'number', 'part_id', 'chapter_id', 'section_id', 'book_id', 'volum_id', 'law_id', 'division_id'];
protected $hidden = ['created_at', 'updated_at'];
@@ -18,7 +18,6 @@ class Gate extends Model
return $this->hasMany(Branch::class);
}
public function art()
{
return $this->hasMany(Art::class);
@@ -38,6 +37,4 @@ class Gate extends Model
{
return self::where('title', 'LIKE', "%{$searchTerm}%")->limit(3)->get();
}
}

View File

@@ -15,7 +15,7 @@ class JudicialPrecedent extends Model
'subject',
'full_text',
'issuing_authority',
'category_id'
'category_id',
];
protected $hidden = ['created_at', 'updated_at'];

View File

@@ -9,11 +9,10 @@ class Law extends Model
{
use HasFactory;
protected $fillable = ['title', 'is_locked', 'category_id', 'price','image'];
protected $fillable = ['title', 'is_locked', 'category_id', 'price', 'image'];
protected $hidden = ['created_at', 'updated_at'];
public function category()
{
return $this->belongsTo(Category::class, 'category_id');
@@ -81,6 +80,6 @@ class Law extends Model
public function getImageAttribute($value)
{
return $value ? secure_asset('images/' . $value) : null;
return $value ? secure_asset('images/'.$value) : null;
}
}

View File

@@ -11,11 +11,11 @@ class LikeArt extends Model
protected $fillable = [
'user_id',
'art_id'
'art_id',
];
public function art()
{
return $this->belongsTo(Art::class);
}
}
}

View File

@@ -11,6 +11,6 @@ class LikeSection extends Model
protected $fillable = [
'section_id',
'user_id'
'user_id',
];
}

View File

@@ -13,6 +13,6 @@ class Note extends Model
'user_id',
'art_id',
'note',
'color_code'
'color_code',
];
}

View File

@@ -16,7 +16,6 @@ class Order extends Model
'transaction_id',
];
public function user()
{
return $this->belongsTo(User::class);
@@ -26,7 +25,7 @@ class Order extends Model
{
return [
'paid' => 'پرداخت شده',
'unpaid' => 'پرداخت نشده'
'unpaid' => 'پرداخت نشده',
];
}
}

View File

@@ -9,11 +9,10 @@ class Part extends Model
{
use HasFactory;
protected $fillable = ['title', 'number', 'chapter_id', 'section_id', 'book_id', 'volum_id', 'law_id','division_id'];
protected $fillable = ['title', 'number', 'chapter_id', 'section_id', 'book_id', 'volum_id', 'law_id', 'division_id'];
protected $hidden = ['created_at', 'updated_at'];
public function gates()
{
return $this->hasMany(Gate::class);
@@ -34,7 +33,6 @@ class Part extends Model
return self::where('title', 'LIKE', "%{$searchTerm}%")->get();
}
public static function searchLimit($searchTerm)
{
return self::where('title', 'LIKE', "%{$searchTerm}%")->limit(3)->get();

View File

@@ -11,10 +11,9 @@ class RecentArt extends Model
protected $fillable = [
'user_id',
'law_id'
'law_id',
];
public function law()
{
return $this->belongsTo(Law::class);

View File

@@ -9,10 +9,10 @@ class Section extends Model
{
use HasFactory;
protected $fillable = ['title', 'number', 'book_id', 'volum_id', 'law_id','division_id'];
protected $fillable = ['title', 'number', 'book_id', 'volum_id', 'law_id', 'division_id'];
protected $hidden = ['created_at', 'updated_at'];
public function chapters()
{
return $this->hasMany(Chapter::class);
@@ -47,17 +47,14 @@ class Section extends Model
{
return $this->hasMany(Art::class);
}
public static function search($searchTerm)
{
return self::where('title', 'LIKE', "%{$searchTerm}%")->get();
}
public static function searchLimit($searchTerm)
{
return self::where('title', 'LIKE', "%{$searchTerm}%")->limit(3)->get();
}
}

View File

@@ -16,7 +16,7 @@ class SubscribePlan extends Model
'is_active',
'is_free',
'type',
'transaction'
'transaction',
];
public function users()

View File

@@ -8,10 +8,10 @@ use Illuminate\Database\Eloquent\Model;
class Suggestion extends Model
{
use HasFactory;
protected $fillable = [
'user_id',
'text'
'text',
];
public function user()

View File

@@ -19,12 +19,12 @@ class UserSubscriber extends Model
'product_id',
'purchased_at',
'last_verified_at',
'is_free'
'is_free',
];
public function subscribe()
{
return $this->belongsTo(SubscribePlan::class,'subscribe_plan_id');
return $this->belongsTo(SubscribePlan::class, 'subscribe_plan_id');
}
public function user()

View File

@@ -14,10 +14,9 @@ class Version extends Model
'number',
'log',
'force_update',
'type'
'type',
];
protected $hidden = [
'created_at',
'updated_at',

View File

@@ -15,12 +15,14 @@ class Volum extends Model
public function law()
{
return $this->belongsTo(Law::class);
return $this->belongsTo(Law::class);
}
public function book()
{
return $this->hasMany(Book::class);
}
public function sections()
{
return $this->hasMany(Section::class);