- Regel je Angebot auf Abruf: alle Mitglieder, nur freigeschaltete Konten, wer einen Artikel besitzt - Freigaben je Angebot und Konto (offer_releases), nie geloescht, nur entzogen; Pflege im Angebot - Pruefung serverseitig in GrantIssuer::claim; Angebote bei Registrierung bleiben regelfrei - Mitgliederseite Angebote: Neu fuer dich (neue Staende besessener Artikel), Zum Uebernehmen, Shop - Migration 2026_12_01_110000, ADR-56, DEPLOYMENT.md Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
57 lines
1.3 KiB
PHP
57 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Domain\Catalog;
|
|
|
|
use App\Models\User;
|
|
use Carbon\CarbonInterface;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* Freigabe eines Kontos für ein Angebot „auf Abruf“ (ADR-56). Gilt je Angebot und Konto, wird nie gelöscht, nur entzogen.
|
|
*/
|
|
class OfferRelease extends Model
|
|
{
|
|
protected $fillable = [
|
|
'offer_id',
|
|
'user_id',
|
|
'granted_by',
|
|
'granted_at',
|
|
'valid_until',
|
|
'revoked_by',
|
|
'revoked_at',
|
|
'reason',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'granted_at' => 'datetime',
|
|
'valid_until' => 'datetime',
|
|
'revoked_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function offer(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Offer::class);
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function grantor(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'granted_by');
|
|
}
|
|
|
|
public function isActiveAt(CarbonInterface $now): bool
|
|
{
|
|
return $this->revoked_at === null
|
|
&& $this->granted_at->lessThanOrEqualTo($now)
|
|
&& ($this->valid_until === null || $this->valid_until->greaterThan($now));
|
|
}
|
|
}
|