feat: add bylaw management features including documents, legal authorities, subject categories, and nodes
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
14
app/Models/BylawCodificationLink.php
Normal file
14
app/Models/BylawCodificationLink.php
Normal 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'];
|
||||
}
|
||||
34
app/Models/BylawDocument.php
Normal file
34
app/Models/BylawDocument.php
Normal 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');
|
||||
}
|
||||
}
|
||||
12
app/Models/BylawLegalAuthority.php
Normal file
12
app/Models/BylawLegalAuthority.php
Normal 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
27
app/Models/BylawNode.php
Normal 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');
|
||||
}
|
||||
}
|
||||
12
app/Models/BylawNodeType.php
Normal file
12
app/Models/BylawNodeType.php
Normal 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'];
|
||||
}
|
||||
17
app/Models/BylawSubjectCategory.php
Normal file
17
app/Models/BylawSubjectCategory.php
Normal 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');
|
||||
}
|
||||
}
|
||||
@@ -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' => 'کیفری',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ class Folder extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'name'
|
||||
'name',
|
||||
];
|
||||
|
||||
public function arts()
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class JudicialPrecedent extends Model
|
||||
'subject',
|
||||
'full_text',
|
||||
'issuing_authority',
|
||||
'category_id'
|
||||
'category_id',
|
||||
];
|
||||
|
||||
protected $hidden = ['created_at', 'updated_at'];
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,11 +11,11 @@ class LikeArt extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'art_id'
|
||||
'art_id',
|
||||
];
|
||||
|
||||
public function art()
|
||||
{
|
||||
return $this->belongsTo(Art::class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,6 @@ class LikeSection extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'section_id',
|
||||
'user_id'
|
||||
'user_id',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -13,6 +13,6 @@ class Note extends Model
|
||||
'user_id',
|
||||
'art_id',
|
||||
'note',
|
||||
'color_code'
|
||||
'color_code',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -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' => 'پرداخت نشده',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -11,10 +11,9 @@ class RecentArt extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'law_id'
|
||||
'law_id',
|
||||
];
|
||||
|
||||
|
||||
public function law()
|
||||
{
|
||||
return $this->belongsTo(Law::class);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class SubscribePlan extends Model
|
||||
'is_active',
|
||||
'is_free',
|
||||
'type',
|
||||
'transaction'
|
||||
'transaction',
|
||||
];
|
||||
|
||||
public function users()
|
||||
|
||||
@@ -8,10 +8,10 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class Suggestion extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'text'
|
||||
'text',
|
||||
];
|
||||
|
||||
public function user()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -14,10 +14,9 @@ class Version extends Model
|
||||
'number',
|
||||
'log',
|
||||
'force_update',
|
||||
'type'
|
||||
'type',
|
||||
];
|
||||
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user