cms/app/Models/NavigationItem.php
Funky Waddle 37ed997989 feat(cms): initialize Laravel project structure and core CMS files
- Added standard Laravel directory structure and configuration.

- Included Svelte and Tailwind configuration for the admin interface.

- Added core PHPUnit and testing scripts.
2026-04-13 12:48:06 -05:00

44 lines
808 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class NavigationItem extends Model
{
//
protected $fillable = [
'label',
'url',
'page_id',
'order',
'parent_id',
'target',
];
public function page()
{
return $this->belongsTo(Page::class);
}
public function parent()
{
return $this->belongsTo(NavigationItem::class, 'parent_id');
}
public function children()
{
return $this->hasMany(NavigationItem::class, 'parent_id')->orderBy('order');
}
public function getFinalUrlAttribute()
{
if ($this->page_id) {
return '/' . $this->page->slug;
}
return $this->url;
}
}