123 lines
4.3 KiB
PHP
123 lines
4.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Services\Util;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
/**
|
|
* App\Models\ShoppingPayment
|
|
*
|
|
* @property int $id
|
|
* @property int $shopping_order_id
|
|
* @property string $clearingtype
|
|
* @property string|null $wallettype
|
|
* @property string|null $onlinebanktransfertype
|
|
* @property string $reference
|
|
* @property int $amount
|
|
* @property string $currency
|
|
* @property string|null $status
|
|
* @property string|null $txaction
|
|
* @property Carbon|null $created_at
|
|
* @property Carbon|null $updated_at
|
|
* @property-read Collection|PaymentTransaction[] $payment_transactions
|
|
* @property-read int|null $payment_transactions_count
|
|
* @property-read ShoppingOrder $shopping_order
|
|
*
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereAmount($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereClearingtype($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereCurrency($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereOnlinebanktransfertype($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereReference($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereShoppingOrderId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereStatus($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereTxaction($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereUpdatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereWallettype($value)
|
|
*
|
|
* @property string|null $mode
|
|
*
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereMode($value)
|
|
*
|
|
* @property int|null $reminder
|
|
* @property Carbon|null $reminder_date
|
|
*
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|ShoppingPayment whereReminder($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|ShoppingPayment whereReminderDate($value)
|
|
*
|
|
* @mixin \Eloquent
|
|
*/
|
|
class ShoppingPayment extends Model
|
|
{
|
|
protected $table = 'shopping_payments';
|
|
|
|
protected $fillable = [
|
|
'shopping_order_id',
|
|
'clearingtype',
|
|
'wallettype',
|
|
'onlinebanktransfertype',
|
|
'reference',
|
|
'amount',
|
|
'currency',
|
|
'status',
|
|
'reminder',
|
|
'reminder_date',
|
|
'txaction',
|
|
'mode',
|
|
];
|
|
|
|
protected $casts = [
|
|
'reminder' => 'integer',
|
|
'reminder_date' => 'datetime',
|
|
];
|
|
|
|
public function shopping_order()
|
|
{
|
|
return $this->belongsTo('App\Models\ShoppingOrder', 'shopping_order_id');
|
|
}
|
|
|
|
public function payment_transactions()
|
|
{
|
|
return $this->hasMany('App\Models\PaymentTransaction', 'shopping_payment_id');
|
|
}
|
|
|
|
public function getPaymentType()
|
|
{
|
|
|
|
if ($this->clearingtype === 'pp') {
|
|
return 'PayPal';
|
|
}
|
|
if ($this->clearingtype === 'cc') {
|
|
return 'Kreditkarte';
|
|
}
|
|
if ($this->clearingtype === 'vor') {
|
|
return 'Vorkasse';
|
|
}
|
|
if ($this->clearingtype === 'elv') {
|
|
return 'SEPA Lastschrift';
|
|
}
|
|
if ($this->clearingtype === 'sb') {
|
|
return 'Sofort Überweisung';
|
|
}
|
|
if ($this->clearingtype === 'fnc') {
|
|
return 'Rechnung';
|
|
}
|
|
if ($this->clearingtype === 'non') {
|
|
return 'keine';
|
|
}
|
|
|
|
return 'keine';
|
|
}
|
|
|
|
public function getPaymentAmount()
|
|
{
|
|
return Util::formatNumber($this->amount / 100).' '.$this->currency;
|
|
}
|
|
}
|