62 lines
1.6 KiB
PHP
62 lines
1.6 KiB
PHP
|
|
<?php
|
|||
|
|
|
|||
|
|
declare(strict_types=1);
|
|||
|
|
|
|||
|
|
namespace App\Models;
|
|||
|
|
|
|||
|
|
use Database\Factories\ProjectFactory;
|
|||
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||
|
|
use Illuminate\Database\Eloquent\Model;
|
|||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Проект (лид-канал) внутри тенанта.
|
|||
|
|
*
|
|||
|
|
* Tenant-aware модель с RLS: SELECT/INSERT/UPDATE/DELETE фильтруются
|
|||
|
|
* политикой `tenant_isolation` по `current_setting('app.current_tenant_id')`.
|
|||
|
|
*
|
|||
|
|
* Источник: db/schema.sql v8.6 §4, table `projects`.
|
|||
|
|
*/
|
|||
|
|
class Project extends Model
|
|||
|
|
{
|
|||
|
|
/** @use HasFactory<ProjectFactory> */
|
|||
|
|
use HasFactory;
|
|||
|
|
|
|||
|
|
protected $fillable = [
|
|||
|
|
'tenant_id',
|
|||
|
|
'name',
|
|||
|
|
'tag',
|
|||
|
|
'type',
|
|||
|
|
'is_active',
|
|||
|
|
'daily_limit_target',
|
|||
|
|
'effective_daily_limit_today',
|
|||
|
|
'effective_limit_calculated_at',
|
|||
|
|
'region_mask',
|
|||
|
|
'region_mode',
|
|||
|
|
'delivery_days_mask',
|
|||
|
|
'assignment_strategy',
|
|||
|
|
'ttfr_target_minutes',
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
protected function casts(): array
|
|||
|
|
{
|
|||
|
|
return [
|
|||
|
|
'is_active' => 'boolean',
|
|||
|
|
'daily_limit_target' => 'integer',
|
|||
|
|
'effective_daily_limit_today' => 'integer',
|
|||
|
|
'region_mask' => 'integer',
|
|||
|
|
'delivery_days_mask' => 'integer',
|
|||
|
|
'ttfr_target_minutes' => 'integer',
|
|||
|
|
'effective_limit_calculated_at' => 'datetime',
|
|||
|
|
'created_at' => 'datetime',
|
|||
|
|
'updated_at' => 'datetime',
|
|||
|
|
];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/** @return BelongsTo<Tenant, $this> */
|
|||
|
|
public function tenant(): BelongsTo
|
|||
|
|
{
|
|||
|
|
return $this->belongsTo(Tenant::class);
|
|||
|
|
}
|
|||
|
|
}
|