gruene-seele/app/Models/ShoppingOrderMargin.php
2021-04-23 14:52:25 +02:00

132 lines
4.4 KiB
PHP

<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use App\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class ShoppingOrderMargin
*
* @property int $id
* @property int $shopping_order_id
* @property int $user_id
* @property float|null $net_price
* @property float|null $net_discount
* @property float|null $net_amount
* @property int|null $m_sponsor_id
* @property float|null $net_partner_commission
* @property Carbon|null $from
* @property bool $paid
* @property bool $cancellation
* @property int $status
* @property string|null $content
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property User $user
* @property ShoppingOrder $shopping_order
* @package App\Models
* @property float|null $from_payment_credit
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin query()
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereCancellation($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereContent($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereFrom($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereFromPaymentCredit($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereMSponsorId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereNetAmount($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereNetDiscount($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereNetPartnerCommission($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereNetPrice($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin wherePaid($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereShoppingOrderId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereUserId($value)
* @mixin \Eloquent
* @property \Illuminate\Support\Carbon|null $partner_commission_pending_to
* @property bool|null $partner_commission_paid
* @property-read User|null $m_sponsor
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin wherePartnerCommissionPaid($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin wherePartnerCommissionPendingTo($value)
*/
class ShoppingOrderMargin extends Model
{
protected $table = 'shopping_order_margins';
protected $casts = [
'shopping_order_id' => 'int',
'user_id' => 'int',
'net_price' => 'float',
'net_discount' => 'float',
'net_amount' => 'float',
'from_payment_credit' => 'float',
'm_sponsor_id' => 'int',
'net_partner_commission' => 'float',
'paid' => 'bool',
'cancellation' => 'bool',
'status' => 'int',
'partner_commission_pending_to' => 'datetime',
'partner_commission_paid' => 'bool',
'user_credit_id' => 'int',
];
protected $dates = [
'from'
];
protected $fillable = [
'shopping_order_id',
'user_id',
'net_price',
'net_discount',
'net_amount',
'from_payment_credit',
'm_sponsor_id',
'net_partner_commission',
'from',
'paid',
'cancellation',
'status',
'partner_commission_pending_to',
'partner_commission_paid',
'user_credit_id',
'content'
];
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
public function shopping_order()
{
return $this->belongsTo(ShoppingOrder::class, 'shopping_order_id');
}
public function m_sponsor_id()
{
return $this->belongsTo(User::class, 'm_sponsor_id');
}
public function m_sponsor()
{
return $this->belongsTo(User::class, 'm_sponsor_id');
}
public function hasPartnerCommission(){
if($this->m_sponsor_id || $this->net_partner_commission > 0){
return true;
}
return false;
}
}