Abo Einmalprodukte und Bestätigung abschließen
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
2bdc9ada3c
commit
2269ce031f
57 changed files with 3647 additions and 371 deletions
101
app/Models/UserAboOneTimeItem.php
Normal file
101
app/Models/UserAboOneTimeItem.php
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Services\Util;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Class UserAboOneTimeItem
|
||||
*
|
||||
* Einmalig dem Abo hinzugefügte Produkte aus dem normalen Bestellsortiment.
|
||||
* Bewusst getrennt von {@see UserAboItem}, damit diese Positionen nie in die
|
||||
* dauerhafte Abo-Logik geraten und nach erfolgreicher Ausführung gelöscht werden.
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_abo_id
|
||||
* @property int $product_id
|
||||
* @property int|null $comp
|
||||
* @property int $qty
|
||||
* @property int|null $confirmed_qty
|
||||
* @property \Illuminate\Support\Carbon|null $confirmed_at
|
||||
* @property float|null $price
|
||||
* @property float|null $price_net
|
||||
* @property float|null $tax_rate
|
||||
* @property float|null $tax
|
||||
* @property float|null $price_vk_net
|
||||
* @property float|null $discount
|
||||
* @property int|null $points
|
||||
* @property int $status
|
||||
* @property-read Product $product
|
||||
* @property-read UserAbo $user_abo
|
||||
*/
|
||||
class UserAboOneTimeItem extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'user_abo_one_time_items';
|
||||
|
||||
protected $casts = [
|
||||
'user_abo_id' => 'int',
|
||||
'product_id' => 'int',
|
||||
'comp' => 'int',
|
||||
'qty' => 'int',
|
||||
'confirmed_qty' => 'int',
|
||||
'confirmed_at' => 'datetime',
|
||||
'price' => 'float',
|
||||
'price_net' => 'float',
|
||||
'tax_rate' => 'float',
|
||||
'tax' => 'float',
|
||||
'price_vk_net' => 'float',
|
||||
'discount' => 'float',
|
||||
'points' => 'int',
|
||||
'status' => 'int',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'user_abo_id',
|
||||
'product_id',
|
||||
'comp',
|
||||
'qty',
|
||||
'confirmed_qty',
|
||||
'confirmed_at',
|
||||
'price',
|
||||
'price_net',
|
||||
'tax_rate',
|
||||
'tax',
|
||||
'price_vk_net',
|
||||
'discount',
|
||||
'points',
|
||||
'status',
|
||||
];
|
||||
|
||||
public function product(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
|
||||
public function user_abo(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(UserAbo::class);
|
||||
}
|
||||
|
||||
public function isConfirmed(): bool
|
||||
{
|
||||
return $this->confirmed_at !== null && $this->confirmed_qty === $this->qty;
|
||||
}
|
||||
|
||||
public function getFormattedPrice(): string
|
||||
{
|
||||
return Util::formatNumber($this->price);
|
||||
}
|
||||
|
||||
public function getFormattedTotalPrice(): string
|
||||
{
|
||||
return Util::formatNumber($this->price * $this->qty);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue