Basic implementation of payment methods
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Scopes\InstancedModel;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $tenant
|
||||
* @property string $slug
|
||||
* @property string $name
|
||||
* @property ?string $description
|
||||
* @property bool $active
|
||||
*/
|
||||
class AvailablePaymentMethod extends InstancedModel
|
||||
{
|
||||
protected $table = 'available_payment_methods';
|
||||
|
||||
protected $fillable = [
|
||||
'tenant',
|
||||
'slug',
|
||||
'name',
|
||||
'description',
|
||||
'active',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'active' => 'boolean',
|
||||
];
|
||||
|
||||
public function paymentMethod(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PaymentMethod::class, 'slug', 'slug');
|
||||
}
|
||||
|
||||
public function events(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Event::class, 'event_payment_methods')->withTimestamps();
|
||||
}
|
||||
}
|
||||
@@ -153,6 +153,10 @@ class Event extends InstancedModel
|
||||
return $this->belongsToMany(EatingHabit::class, 'event_allowed_eating_habits', 'event_id', 'eating_habit_id');
|
||||
}
|
||||
|
||||
public function paymentMethods() : BelongsToMany {
|
||||
return $this->belongsToMany(AvailablePaymentMethod::class, 'event_payment_methods', 'event_id', 'available_payment_method_id')->withTimestamps();
|
||||
}
|
||||
|
||||
public function resetContributingLocalGroups() {
|
||||
$this->localGroups()->detach();
|
||||
$this->save();
|
||||
@@ -163,6 +167,11 @@ class Event extends InstancedModel
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function resetPaymentMethods() {
|
||||
$this->paymentMethods()->detach();
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function resetMangers() {
|
||||
$this->eventManagers()->detach();
|
||||
$this->save();
|
||||
|
||||
@@ -64,6 +64,7 @@ class EventParticipant extends InstancedModel
|
||||
'amount',
|
||||
'amount_paid',
|
||||
'payment_purpose',
|
||||
'payment_method',
|
||||
'efz_status',
|
||||
'unregistered_at',
|
||||
];
|
||||
@@ -126,6 +127,11 @@ class EventParticipant extends InstancedModel
|
||||
return $this->belongsTo(EatingHabit::class, 'eating_habits', 'slug');
|
||||
}
|
||||
|
||||
public function paymentMethod()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\PaymentMethod::class, 'payment_method', 'slug');
|
||||
}
|
||||
|
||||
public function firstAidPermission()
|
||||
{
|
||||
return $this->belongsTo(FirstAidPermission::class, 'first_aid_permission', 'slug');
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Scopes\CommonModel;
|
||||
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
||||
|
||||
/**
|
||||
* @property string $id
|
||||
* @property string $slug
|
||||
*/
|
||||
class PaymentMethod extends CommonModel
|
||||
{
|
||||
use HasUuids;
|
||||
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
public const string PAYMENT_ACCOUNT_TRANSACTION = 'PAYMENT_ACCOUNT_TRANSACTION';
|
||||
public const string PAYMENT_NOT_DEFINED = 'PAYMENT_NOT_DEFINED';
|
||||
|
||||
public const array DEFAULTS = [
|
||||
self::PAYMENT_ACCOUNT_TRANSACTION => ['name' => 'Überweisung auf Veranstaltungskonto', 'description' => null],
|
||||
self::PAYMENT_NOT_DEFINED => ['name' => 'Sonstiges (Barzahlung, Zahlung vor Ort)', 'description' => null],
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'slug',
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user