feat(Category): add category
This commit is contained in:
@@ -14,7 +14,8 @@ class JudicialPrecedent extends Model
|
||||
'ruling_date',
|
||||
'subject',
|
||||
'full_text',
|
||||
'issuing_authority'
|
||||
'issuing_authority',
|
||||
'category_id'
|
||||
];
|
||||
|
||||
protected $hidden = ['created_at', 'updated_at'];
|
||||
@@ -23,4 +24,9 @@ class JudicialPrecedent extends Model
|
||||
{
|
||||
return $this->belongsToMany(Art::class, 'art_judicial_precedent');
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(JudicialPrecedentCategory::class, 'category_id');
|
||||
}
|
||||
}
|
||||
|
||||
18
app/Models/JudicialPrecedentCategory.php
Normal file
18
app/Models/JudicialPrecedentCategory.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class JudicialPrecedentCategory extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['name'];
|
||||
|
||||
public function judicialPrecedents()
|
||||
{
|
||||
return $this->hasMany(JudicialPrecedent::class, 'category_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user