fix: complete InvesteMoz validation and error corrections
This commit is contained in:
@@ -2,4 +2,10 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
/**
|
||||
* @property string|null $external_id
|
||||
* @property string|null $source_system
|
||||
* @property string $full_name
|
||||
* @property string|null $phone
|
||||
*/
|
||||
class Contact extends CrmRecord {}
|
||||
|
||||
@@ -10,6 +10,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @property string $validation_status
|
||||
* @property string $valid_from
|
||||
* @property string|null $valid_until
|
||||
* @property array<string, mixed>|null $fiscal_acceptance
|
||||
*/
|
||||
class InvestmentLegalSource extends Model
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ class InvestmentZone extends DomainRecord
|
||||
{
|
||||
protected $hidden = ['editorial_draft', 'operational_details'];
|
||||
|
||||
protected $casts = ['operational_details' => 'array', 'operational_details' => 'array', 'version_no' => 'integer', 'published_at' => 'datetime', 'aliases' => 'array', 'activities' => 'array', 'resources' => 'array', 'historical_territory' => 'array', 'area_components' => 'array', 'source_evidence' => 'array', 'area_value' => 'decimal:4', 'data_as_of' => 'date', 'sources_consulted_at' => 'date'];
|
||||
protected $casts = ['operational_details' => 'array', 'version_no' => 'integer', 'published_at' => 'datetime', 'aliases' => 'array', 'activities' => 'array', 'resources' => 'array', 'historical_territory' => 'array', 'area_components' => 'array', 'source_evidence' => 'array', 'area_value' => 'decimal:4', 'data_as_of' => 'date', 'sources_consulted_at' => 'date'];
|
||||
|
||||
/** @return BelongsTo<GeoLocation, $this> */
|
||||
public function primaryTerritory(): BelongsTo
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Services\OpportunityMaturity;
|
||||
use App\Services\OpportunityPublicText;
|
||||
use App\Services\ProactiveInvestment;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@@ -34,8 +37,13 @@ class Opportunity extends Model
|
||||
public function toArray(): array
|
||||
{
|
||||
$data = parent::toArray();
|
||||
if (isset($data['description'])) $data['description'] = \App\Services\OpportunityPublicText::description($this, $data['description']);
|
||||
if ($this->exists && ($proactive = app(\App\Services\ProactiveInvestment::class)->publicData($this))) $data['proactive'] = $proactive;
|
||||
if (isset($data['description'])) {
|
||||
$data['description'] = OpportunityPublicText::description($this, $data['description']);
|
||||
}
|
||||
if ($this->exists && ($proactive = app(ProactiveInvestment::class)->publicData($this))) {
|
||||
$data['proactive'] = $proactive;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -44,7 +52,7 @@ class Opportunity extends Model
|
||||
// Only published metadata is public; never expose the current private draft.
|
||||
$version = data_get($this->workflow_context, 'publication.maturity.catalogue_version');
|
||||
|
||||
return in_array($version, [\App\Services\OpportunityMaturity::VERSION, \App\Services\OpportunityMaturity::LEGACY], true)
|
||||
return in_array($version, [OpportunityMaturity::VERSION, OpportunityMaturity::LEGACY], true)
|
||||
? $version : null;
|
||||
}
|
||||
|
||||
|
||||
+15
-4
@@ -2,10 +2,15 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* @property list<array<string, mixed>> $specializations
|
||||
* @property string $url
|
||||
*/
|
||||
class Sector extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
@@ -20,18 +25,24 @@ class Sector extends Model
|
||||
'published_at' => 'datetime',
|
||||
];
|
||||
|
||||
/** Presentation only: historical masters and foreign keys remain untouched. */
|
||||
public function scopeChoices($query)
|
||||
/** Presentation only: historical masters and foreign keys remain untouched.
|
||||
* @param Builder<Sector> $query
|
||||
* @return Builder<Sector>
|
||||
*/
|
||||
public function scopeChoices(Builder $query): Builder
|
||||
{
|
||||
return $query->where('is_active', true)->where('slug', '!=', 'energia');
|
||||
}
|
||||
|
||||
public function scopeCatalog($query)
|
||||
/** @param Builder<Sector> $query
|
||||
* @return Builder<Sector>
|
||||
*/
|
||||
public function scopeCatalog(Builder $query): Builder
|
||||
{
|
||||
return $query->choices()->whereNotNull('published_at')->where('slug', '!=', 'fintech');
|
||||
}
|
||||
|
||||
public function getNameAttribute($value)
|
||||
public function getNameAttribute(?string $value): ?string
|
||||
{
|
||||
return ($this->attributes['slug'] ?? null) === 'fintech' ? 'Mercado Financeiro — Fintech' : $value;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@ use Illuminate\Support\Carbon;
|
||||
* @property string $component
|
||||
* @property string $scope_key
|
||||
* @property string $status
|
||||
* @property array<string, mixed> $rule_definition
|
||||
* @property array<string, mixed> $parameters
|
||||
* @property array<string, mixed> $rounding_policy
|
||||
* @property int $author_id
|
||||
* @property int|null $reviewer_id
|
||||
* @property int|null $approver_id
|
||||
|
||||
Reference in New Issue
Block a user