Files
Investidor-V2/app/Models/Sector.php
nala cf003c8623
tests / ci (push) Canceled after 0s
versao nrgocios 4
2026-10-18 15:57:06 +02:00

45 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class Sector extends Model
{
use SoftDeletes;
protected $fillable = [
'name', 'slug', 'short_description', 'description',
'icon', 'sort_order', 'is_active', 'published_at',
];
protected $casts = [
'is_active' => 'boolean',
'published_at' => 'datetime',
];
/** Presentation only: historical masters and foreign keys remain untouched. */
public function scopeChoices($query)
{
return $query->where('is_active', true)->where('slug', '!=', 'energia');
}
public function scopeCatalog($query)
{
return $query->choices()->whereNotNull('published_at')->where('slug', '!=', 'fintech');
}
public function getNameAttribute($value)
{
return ($this->attributes['slug'] ?? null) === 'fintech' ? 'Mercado Financeiro — Fintech' : $value;
}
/** @return HasMany<Opportunity, $this> */
public function opportunities(): HasMany
{
return $this->hasMany(Opportunity::class);
}
}