Files
Investidor-V2/app/Models/ExistingBusiness.php
nala e65cb26901
tests / ci (push) Canceled after 0s
varias alteracoes
2026-10-06 14:50:12 +02:00

53 lines
1.6 KiB
PHP

<?php
namespace App\Models;
use Carbon\CarbonImmutable;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* @property string|null $public_slug
* @property string|null $public_title
* @property string|null $activity_code
* @property string|null $stage
* @property string|null $objective
* @property string|null $currency
* @property string|null $amount_min
* @property string|null $amount_max
* @property string|null $available_percentage
* @property CarbonImmutable|null $published_at
* @property-read Sector|null $sector
*/
class ExistingBusiness extends DomainRecord
{
protected $hidden = ['payload'];
protected $casts = [
'payload' => 'encrypted:array',
'version_no' => 'integer',
'amount_min' => 'decimal:2',
'amount_max' => 'decimal:2',
'available_percentage' => 'decimal:2',
'submitted_at' => 'immutable_datetime',
'published_at' => 'immutable_datetime',
'expires_at' => 'immutable_datetime',
'next_action_due_at' => 'immutable_datetime',
];
/** @return BelongsTo<Sector, $this> */
public function sector(): BelongsTo
{
return $this->belongsTo(Sector::class);
}
/** @param Builder<ExistingBusiness> $query
* @return Builder<ExistingBusiness>
*/
public function scopePublished(Builder $query): Builder
{
return $query->where('status', 'published')->whereNotNull('published_at')->where('published_at', '<=', now())
->where(fn (Builder $q) => $q->whereNull('expires_at')->orWhere('expires_at', '>=', today()));
}
}