feat: add legal opinions admin management
This commit is contained in:
@@ -53,6 +53,11 @@ class Art extends Model
|
||||
return $this->belongsToMany(JudicialPrecedent::class, 'art_judicial_precedent');
|
||||
}
|
||||
|
||||
public function legalOpinions()
|
||||
{
|
||||
return $this->belongsToMany(LegalOpinion::class, 'art_legal_opinion');
|
||||
}
|
||||
|
||||
public static function search($searchTerm)
|
||||
{
|
||||
return self::where('title', 'LIKE', "%{$searchTerm}%")
|
||||
|
||||
32
app/Models/LegalOpinion.php
Normal file
32
app/Models/LegalOpinion.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LegalOpinion extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'opinion_number',
|
||||
'opinion_date',
|
||||
'subject',
|
||||
'full_text',
|
||||
'issuing_authority',
|
||||
'category_id',
|
||||
];
|
||||
|
||||
protected $hidden = ['created_at', 'updated_at'];
|
||||
|
||||
public function arts()
|
||||
{
|
||||
return $this->belongsToMany(Art::class, 'art_legal_opinion');
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(LegalOpinionCategory::class, 'category_id');
|
||||
}
|
||||
}
|
||||
18
app/Models/LegalOpinionCategory.php
Normal file
18
app/Models/LegalOpinionCategory.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LegalOpinionCategory extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['name'];
|
||||
|
||||
public function legalOpinions()
|
||||
{
|
||||
return $this->hasMany(LegalOpinion::class, 'category_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user