44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Opportunity extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'sector_id', 'reference', 'title', 'slug', 'summary', 'description',
|
|
'province', 'district', 'promoter_name', 'promoter_type',
|
|
'maturity_level', 'maturity_label', 'estimated_investment_amount',
|
|
'estimated_investment_currency', 'financing_modality',
|
|
'expected_impact', 'status', 'is_featured', 'published_at',
|
|
'last_validated_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'is_featured' => 'boolean',
|
|
'published_at' => 'datetime',
|
|
'last_validated_at' => 'datetime',
|
|
'estimated_investment_amount' => 'decimal:2',
|
|
];
|
|
|
|
/** @return BelongsTo<Sector, $this> */
|
|
public function sector(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Sector::class);
|
|
}
|
|
|
|
/** @param Builder<Opportunity> $query
|
|
* @return Builder<Opportunity>
|
|
*/
|
|
public function scopePublished(Builder $query): Builder
|
|
{
|
|
return $query->where('status', 'published')->whereNotNull('published_at')->where('published_at', '<=', now());
|
|
}
|
|
}
|