MiknasTrading/app/Models/Settings/ProjectSetting.php
Ghassan Yusuf 7f8ae898d5 feat: add Projects settings with sub-locations and cascading dropdowns in purchase request modal
- Migration: add project_id FK to settings_locations
- Models: ProjectSetting hasMany Location, Location belongsTo ProjectSetting
- Settings: /settings/projects page — manage projects and their sub-locations (two-panel UI)
- Sidebar: Projects nav item under Settings group
- Routes: 7 new settings/projects routes (Admin only)
- Modal: project_name and location fields now cascading dropdowns populated from settings_projects/settings_locations

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-25 11:31:12 +03:00

25 lines
544 B
PHP

<?php
namespace App\Models\Settings;
use Illuminate\Database\Eloquent\Model;
class ProjectSetting extends Model
{
protected $table = 'settings_projects';
protected $fillable = ['name', 'is_active'];
protected $casts = ['is_active' => 'boolean'];
public function scopeActive($query)
{
return $query->where('is_active', true);
}
public function locations(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(\App\Models\Settings\Location::class, 'project_id');
}
}