Files
Investidor-V2/app/Models/ExistingBusiness.php
T
nala 4f35313d06
tests / ci (push) Canceled after 0s
novas funcionalidades dos formulario
2026-10-02 11:13:37 +02:00

39 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
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()));
}
}