- Implement OfferOptionAdminTest to validate offer option management, including price display, activation, and cancellation. - Create OrganizationPurchaseTest to ensure correct handling of organization purchases, including access control and order processing. - Add ShopProductPageTest to verify shop product listings, search functionality, and product page details. - Introduce BuildsShop trait for seeding test data related to shop functionality. - Implement MoneyTest to validate money parsing and formatting, ensuring correct handling of euro amounts.
53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Domain\Identity;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* Mitgliedschaft eines Kontos in einer Organisation (Domänenmodell 04, MEMBERSHIP). Etappe 1 nutzt sie für die
|
|
* Bestellberechtigung: Ein Konto bestellt nur für eine Organisation, bei der eine aktive Mitgliedschaft mit
|
|
* `may_order` besteht. Sitzpools und Selbstverwaltung folgen mit A4.
|
|
*/
|
|
class Membership extends Model
|
|
{
|
|
protected $fillable = [
|
|
'user_id',
|
|
'party_id',
|
|
'role',
|
|
'may_order',
|
|
'valid_from',
|
|
'valid_until',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'may_order' => 'boolean',
|
|
'valid_from' => 'date',
|
|
'valid_until' => 'date',
|
|
];
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function organisation(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Party::class, 'party_id');
|
|
}
|
|
|
|
/** Mitgliedschaften, die heute gelten. */
|
|
public function scopeActive(Builder $query): Builder
|
|
{
|
|
return $query
|
|
->where(fn (Builder $inner) => $inner->whereNull('valid_from')->orWhereDate('valid_from', '<=', now()))
|
|
->where(fn (Builder $inner) => $inner->whereNull('valid_until')->orWhereDate('valid_until', '>=', now()));
|
|
}
|
|
}
|