reconstruction of the project

This commit is contained in:
root
2026-03-08 16:33:24 -04:00
parent 23b7db1107
commit c8de5f7edc
9157 changed files with 77877 additions and 1073823 deletions
+36 -8
View File
@@ -3,13 +3,17 @@
namespace App\Models;
use App\Models\BaseModel;
use Illuminate\Database\Eloquent\SoftDeletes;
class NavItem extends BaseModel
{
protected $table = 'nav_items';
protected $primaryKey = 'id';
// ✅ CI: timestamps + soft deletes
use SoftDeletes;
public $timestamps = true;
protected $useSoftDeletes = true;
protected $fillable = [
'menu_parent_id',
'label',
@@ -23,11 +27,35 @@ class NavItem extends BaseModel
'deleted_at',
];
public function getChildrenOf(int $parentId): array
protected $casts = [
'menu_parent_id' => 'integer',
'sort_order' => 'integer',
'is_enabled' => 'boolean',
];
/* Optional relationships */
public function parent()
{
return $this->where('parent_id', $parentId)
->where('is_enabled', 1)
->orderBy('sort_order', 'ASC')
->findAll();
return $this->belongsTo(self::class, 'menu_parent_id');
}
}
public function children()
{
return $this->hasMany(self::class, 'menu_parent_id');
}
/**
* Equivalent of CI getChildrenOf()
* NOTE: CI code uses where('parent_id', ...) but allowedFields has menu_parent_id.
* This Laravel version uses menu_parent_id (likely correct).
*/
public static function getChildrenOf(int $parentId): array
{
return static::query()
->where('menu_parent_id', $parentId)
->where('is_enabled', 1)
->orderBy('sort_order', 'asc')
->get()
->toArray();
}
}