- Company → Project → (Locations + Departments) hierarchy - Company CRUD (add, edit, delete) with AJAX - Projects are created under a company via inline strip - Two-column project body: Locations | Departments - Stats show companies, projects, locations, departments, active projects - Dynamic stat counters update on add/delete without page reload Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
35 lines
896 B
PHP
35 lines
896 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', 'company_id'];
|
|
|
|
protected $casts = ['is_active' => 'boolean'];
|
|
|
|
public function scopeActive($query)
|
|
{
|
|
return $query->where('is_active', true);
|
|
}
|
|
|
|
public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
{
|
|
return $this->belongsTo(Company::class, 'company_id');
|
|
}
|
|
|
|
public function locations(): \Illuminate\Database\Eloquent\Relations\HasMany
|
|
{
|
|
return $this->hasMany(\App\Models\Settings\Location::class, 'project_id');
|
|
}
|
|
|
|
public function departments(): \Illuminate\Database\Eloquent\Relations\HasMany
|
|
{
|
|
return $this->hasMany(\App\Models\Settings\Department::class, 'project_id');
|
|
}
|
|
}
|