Changes to UI and other stuff

This commit is contained in:
Simon Pocrnjič
2025-11-20 18:11:43 +01:00
parent b7fa2d261b
commit 3b284fa4bd
87 changed files with 7872 additions and 2330 deletions
+18
View File
@@ -3,6 +3,8 @@
namespace App\Models;
use App\Traits\Uuid;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
@@ -55,6 +57,7 @@ protected function startDate(): Attribute
return null;
}
$str = is_string($value) ? $value : (string) $value;
return \App\Services\DateNormalizer::toDate($str);
}
);
@@ -71,11 +74,26 @@ protected function endDate(): Attribute
return null;
}
$str = is_string($value) ? $value : (string) $value;
return \App\Services\DateNormalizer::toDate($str);
}
);
}
/**
* Scope contracts to those in a specific segment with active pivot.
*/
#[Scope]
public function scopeForSegment(Builder $query, int $segmentId): Builder
{
return $query->whereExists(function ($q) use ($segmentId) {
$q->from('contract_segment')
->whereColumn('contract_segment.contract_id', 'contracts.id')
->where('contract_segment.segment_id', $segmentId)
->where('contract_segment.active', true);
});
}
public function type(): BelongsTo
{
return $this->belongsTo(\App\Models\ContractType::class, 'type_id');