<?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
 */
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'
	];

	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',
		'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');
    }
}
