Initial Commit
This commit is contained in:
28
app/Models/ParentCategory.php
Normal file
28
app/Models/ParentCategory.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
|
||||
|
||||
class ParentCategory extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use Sluggable;
|
||||
|
||||
protected $fillable = ["name", "slug", "ordering"];
|
||||
|
||||
public function sluggable(): array {
|
||||
return [
|
||||
"slug" => [
|
||||
'source' => 'name'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function children() {
|
||||
return $this->hasMany(Category::class, 'parent', 'id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user