User Order all Margins / Checkout
This commit is contained in:
parent
a96d7d5c77
commit
224bf9e951
92 changed files with 3551 additions and 561 deletions
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Services\Util;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
|
|
@ -35,6 +36,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereShowAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $max_price
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PaymentMethod whereMaxPrice($value)
|
||||
*/
|
||||
class PaymentMethod extends Model
|
||||
{
|
||||
|
|
@ -52,6 +55,7 @@ class PaymentMethod extends Model
|
|||
'name',
|
||||
'short',
|
||||
'show_at',
|
||||
'max_price',
|
||||
'pos',
|
||||
'default',
|
||||
'active'
|
||||
|
|
@ -59,11 +63,11 @@ class PaymentMethod extends Model
|
|||
|
||||
public static $showATs = [
|
||||
0 => 'Nur Kunden Shop',
|
||||
1 => 'Nur Berater Shop',
|
||||
2 => 'Kunden + Berater Shop',
|
||||
3 => 'Nur Reg/Mitgliedschaft Berater',
|
||||
4 => 'Kunden + Berater Shop + Reg/Mitgliedschaft',
|
||||
5 => 'Berater Shop + Reg/Mitgliedschaft',
|
||||
1 => 'Nur Vertriebspartner Shop',
|
||||
2 => 'Kunden + Vertriebspartner Shop',
|
||||
3 => 'Nur Reg/Mitgliedschaft Vertriebspartner',
|
||||
4 => 'Kunden + Vertriebspartner Shop + Reg/Mitgliedschaft',
|
||||
5 => 'Vertriebspartner Shop + Reg/Mitgliedschaft',
|
||||
9 => 'überall',
|
||||
];
|
||||
|
||||
|
|
@ -74,4 +78,37 @@ class PaymentMethod extends Model
|
|||
public static function getDefaultAsArray($short=false){
|
||||
return PaymentMethod::where('active', true)->where('default', true)->pluck('id');
|
||||
}
|
||||
|
||||
public function setMaxPriceAttribute($value)
|
||||
{
|
||||
$this->attributes['max_price'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
|
||||
public function getFormattedMaxPrice()
|
||||
{
|
||||
return isset($this->attributes['max_price']) ? Util::formatNumber($this->attributes['max_price']) : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $short //PP FNC VOR CC SB ...
|
||||
* @param $user_payment_methods //PaymentMethod [] IDs
|
||||
* @param $total //Full price
|
||||
*/
|
||||
public static function isShowPaymentMethod($short, $user_payment_methods, $total = 0){
|
||||
|
||||
$payment_method = PaymentMethod::whereShort($short)->first();
|
||||
|
||||
if($payment_method && $payment_method->active){
|
||||
if(in_array($payment_method->id, $user_payment_methods)){
|
||||
if($payment_method->max_price > 0){
|
||||
if($payment_method->max_price >= $total){
|
||||
return true;
|
||||
}
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,13 +103,20 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @property-read int|null $country_prices_count
|
||||
* @property int|null $wp_number
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereWpNumber($value)
|
||||
* @property bool|null $shipping_addon
|
||||
* @property bool|null $single_commission
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereShippingAddon($value)
|
||||
* @property-read int|null $ingredients_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductIngredient[] $product_ingredients
|
||||
* @property-read int|null $product_ingredients_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Ingredient[] $p_ingredients
|
||||
* @property-read int|null $p_ingredients_count
|
||||
* @property bool $amount_commission
|
||||
* @property string|null $value_commission
|
||||
* @property string|null $partner_commission
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereAmountCommission($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product wherePartnerCommission($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereSingleCommission($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereValueCommission($value)
|
||||
*/
|
||||
class Product extends Model
|
||||
{
|
||||
|
|
@ -132,7 +139,8 @@ class Product extends Model
|
|||
'trans_ingredients' => 'array',
|
||||
'action' => 'array',
|
||||
'wp_number' => 'int',
|
||||
'shipping_addon' => 'bool',
|
||||
'single_commission' => 'bool',
|
||||
'amount_commission' => 'bool',
|
||||
'active' => 'bool'
|
||||
];
|
||||
use Sluggable;
|
||||
|
|
@ -164,7 +172,10 @@ class Product extends Model
|
|||
'amount',
|
||||
'active',
|
||||
'show_at',
|
||||
'shipping_addon',
|
||||
'single_commission',
|
||||
'amount_commission',
|
||||
'value_commission',
|
||||
'partner_commission',
|
||||
'identifier',
|
||||
'action',
|
||||
'upgrade_to_id'
|
||||
|
|
@ -175,8 +186,8 @@ class Product extends Model
|
|||
'show_upgrade' => 'Kann geupdatet werden',
|
||||
'show_order' => 'Wird immer als Option angezeigt',
|
||||
'upgrade' => 'Produktupgrade zur Produkt ID',
|
||||
'upgrade_member' => 'Beraterupgrade zur Karriere ID',
|
||||
//'proportional_voucher' => 'Anteiliger Gutschein Berater',
|
||||
'upgrade_member' => 'Vertriebspartnerupgrade zur Karriere ID',
|
||||
//'proportional_voucher' => 'Anteiliger Gutschein Vertriebspartner',
|
||||
|
||||
|
||||
];
|
||||
|
|
@ -190,12 +201,12 @@ class Product extends Model
|
|||
|
||||
public $showATs = [
|
||||
0 => 'Nur Kunden Bestellungen',
|
||||
1 => 'Kunden + Berater Bestellungen',
|
||||
2 => 'Nur Berater Bestellungen',
|
||||
3 => 'Registrierung / Mitgliedschaft Berater',
|
||||
4 => 'Nur Mitgliedschaft Berater',
|
||||
//5 => 'Onboarding Berater',
|
||||
//6 => 'Onboarding Berater + Berater Shop',
|
||||
1 => 'Kunden + Vertriebspartner Bestellungen',
|
||||
2 => 'Nur Vertriebspartner Bestellungen',
|
||||
3 => 'Registrierung / Mitgliedschaft Vertriebspartner',
|
||||
4 => 'Nur Mitgliedschaft Vertriebspartner',
|
||||
//5 => 'Onboarding Vertriebspartner',
|
||||
//6 => 'Onboarding Vertriebspartner + Vertriebspartner Shop',
|
||||
7 => 'zur internen Berechnung',
|
||||
|
||||
];
|
||||
|
|
@ -279,6 +290,14 @@ class Product extends Model
|
|||
$this->attributes['price_old'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
|
||||
public function setValueCommissionAttribute( $value ) {
|
||||
$this->attributes['value_commission'] = $value ? Util::reFormatNumber($value) : 0;
|
||||
}
|
||||
|
||||
public function setPartnerCommissionAttribute( $value ) {
|
||||
$this->attributes['partner_commission'] = $value ? Util::reFormatNumber($value) : 0;
|
||||
}
|
||||
|
||||
public function getFormattedPrice()
|
||||
{
|
||||
return isset($this->attributes['price']) ? Util::formatNumber($this->attributes['price']) : "";
|
||||
|
|
@ -298,6 +317,16 @@ class Product extends Model
|
|||
{
|
||||
return isset($this->attributes['price_old']) ? Util::formatNumber($this->attributes['price_old']) : "";
|
||||
}
|
||||
public function getFormattedValueCommission()
|
||||
{
|
||||
return isset($this->attributes['value_commission']) ? Util::formatNumber($this->attributes['value_commission']) : 0;
|
||||
}
|
||||
|
||||
public function getFormattedPartnerCommission()
|
||||
{
|
||||
return isset($this->attributes['partner_commission']) ? Util::formatNumber($this->attributes['partner_commission']) : 0;
|
||||
}
|
||||
|
||||
|
||||
/*price by user Factor*/
|
||||
private function calcPriceUserFactor($price){
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
/**
|
||||
* Class Setting
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property string|null $identifier
|
||||
* @property string $slug
|
||||
|
|
@ -23,8 +23,27 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property int $status
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*
|
||||
* @package App\Models
|
||||
* @property string|null $full_text
|
||||
* @property string|null $text
|
||||
* @property string|null $type
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting findSimilarSlugs(string $attribute, array $config, string $slug)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereAction($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereFullText($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereIdentifier($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereObject($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereReferenz($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereText($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Setting extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingOrder withoutTrashed()
|
||||
* @property-read \App\Models\ShippingCountry $shipping_country
|
||||
* @property float|null $shipping_net
|
||||
* @property float|null $subtotal_ws
|
||||
* @property float|null $subtotal_shipping
|
||||
* @property int|null $points
|
||||
* @property int|null $shipped
|
||||
* @property string|null $tracking
|
||||
|
|
@ -82,6 +82,15 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereWpInvoicePath($value)
|
||||
* @property array|null $wp_notice
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereWpNotice($value)
|
||||
* @property string|null $subtotal_full
|
||||
* @property-read \App\Models\ShoppingOrderMargin|null $shopping_order_margin
|
||||
* @property-read \App\Models\ShoppingPayment|null $shopping_payment_last
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereSubtotalFull($value)
|
||||
* @property string|null $discount
|
||||
* @property string|null $payment_credit
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereDiscount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder wherePaymentCredit($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereSubtotalShipping($value)
|
||||
*/
|
||||
class ShoppingOrder extends Model
|
||||
{
|
||||
|
|
@ -97,11 +106,15 @@ class ShoppingOrder extends Model
|
|||
'country_id',
|
||||
'user_shop_id',
|
||||
'total',
|
||||
'subtotal_full',
|
||||
'discount',
|
||||
'subtotal',
|
||||
'shipping',
|
||||
'shipping_net',
|
||||
'subtotal_ws',
|
||||
'subtotal_shipping',
|
||||
'tax',
|
||||
'total_without_credit',
|
||||
'payment_credit',
|
||||
'total_shipping',
|
||||
'points',
|
||||
'weight',
|
||||
|
|
@ -176,6 +189,10 @@ class ShoppingOrder extends Model
|
|||
return $this->hasOne('App\Models\UserHistory','shopping_order_id')->latest();
|
||||
}
|
||||
|
||||
public function shopping_order_margin()
|
||||
{
|
||||
return $this->hasOne('App\Models\ShoppingOrderMargin','shopping_order_id')->latest();
|
||||
}
|
||||
|
||||
public function shopping_order_items(){
|
||||
return $this->hasMany('App\Models\ShoppingOrderItem', 'shopping_order_id');
|
||||
|
|
@ -228,11 +245,21 @@ class ShoppingOrder extends Model
|
|||
return formatNumber($this->attributes['total']);
|
||||
}
|
||||
|
||||
public function getFormattedSubtotalFull()
|
||||
{
|
||||
return formatNumber($this->attributes['subtotal_full']);
|
||||
}
|
||||
|
||||
public function getFormattedSubtotal()
|
||||
{
|
||||
return formatNumber($this->attributes['subtotal']);
|
||||
}
|
||||
|
||||
public function getFormattedDiscount()
|
||||
{
|
||||
return formatNumber($this->attributes['discount']);
|
||||
}
|
||||
|
||||
public function getFormattedShipping()
|
||||
{
|
||||
return formatNumber($this->attributes['shipping']);
|
||||
|
|
@ -243,15 +270,24 @@ class ShoppingOrder extends Model
|
|||
return formatNumber($this->attributes['shipping_net']);
|
||||
}
|
||||
|
||||
public function getFormattedSubtotalWs()
|
||||
public function getFormattedSubtotalShipping()
|
||||
{
|
||||
return formatNumber($this->attributes['subtotal_ws']);
|
||||
return formatNumber($this->attributes['subtotal_shipping']);
|
||||
}
|
||||
|
||||
public function getFormattedTax()
|
||||
{
|
||||
return formatNumber($this->attributes['tax']);
|
||||
}
|
||||
public function getFormattedTotalWithoutCredit()
|
||||
{
|
||||
return formatNumber($this->attributes['total_without_credit']);
|
||||
}
|
||||
public function getFormattedPaymentCredit()
|
||||
{
|
||||
return formatNumber($this->attributes['payment_credit']);
|
||||
}
|
||||
|
||||
|
||||
public function getFormattedTotalShipping()
|
||||
{
|
||||
|
|
|
|||
108
app/Models/ShoppingOrderMargin.php
Normal file
108
app/Models/ShoppingOrderMargin.php
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
<?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');
|
||||
}
|
||||
}
|
||||
|
|
@ -31,15 +31,21 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property array|null $trans_content
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereContent($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereTransContent($value)
|
||||
* @property bool $partner_provision
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UserLevelMargin[] $user_level_margins
|
||||
* @property-read int|null $user_level_margins_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UserLevelMargin[] $user_level_margins_re
|
||||
* @property-read int|null $user_level_margins_re_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePartnerProvision($value)
|
||||
*/
|
||||
class UserLevel extends Model
|
||||
{
|
||||
protected $table = 'user_levels';
|
||||
|
||||
protected $casts = ['trans_name' => 'array', 'trans_content' => 'array'];
|
||||
protected $casts = ['trans_name' => 'array', 'trans_content' => 'array', 'partner_provision'=>'bool'];
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'content', 'pos', 'active',
|
||||
'name', 'content', 'pos', 'active', 'partner_provision',
|
||||
];
|
||||
|
||||
|
||||
|
|
@ -49,6 +55,17 @@ class UserLevel extends Model
|
|||
}
|
||||
*/
|
||||
|
||||
|
||||
public function user_level_margins()
|
||||
{
|
||||
return $this->hasMany('App\Models\UserLevelMargin', 'user_level_id', 'id');
|
||||
}
|
||||
|
||||
public function user_level_margins_re()
|
||||
{
|
||||
return $this->hasMany('App\Models\UserLevelMargin', 'user_level_id', 'id')->orderBy('price_from', 'DESC');
|
||||
}
|
||||
|
||||
public function setPosAttribute($value){
|
||||
$this->attributes['pos'] = is_numeric($value) ? $value : null;
|
||||
|
||||
|
|
|
|||
90
app/Models/UserLevelMargin.php
Normal file
90
app/Models/UserLevelMargin.php
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Services\Util;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class UserLevelMargin
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_level_id
|
||||
* @property float|null $price_from
|
||||
* @property float|null $trading_margin
|
||||
* @property float|null $commission
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property UserLevel $user_level
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevelMargin newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevelMargin newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevelMargin query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevelMargin whereCommission($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevelMargin whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevelMargin whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevelMargin wherePriceFrom($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevelMargin whereTradingMargin($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevelMargin whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevelMargin whereUserLevelId($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserLevelMargin extends Model
|
||||
{
|
||||
protected $table = 'user_level_margins';
|
||||
|
||||
protected $casts = [
|
||||
'user_level_id' => 'int',
|
||||
'price_from' => 'float',
|
||||
'trading_margin' => 'float',
|
||||
'commission' => 'float'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'user_level_id',
|
||||
'price_from',
|
||||
'trading_margin',
|
||||
'commission'
|
||||
];
|
||||
|
||||
public function user_level()
|
||||
{
|
||||
return $this->belongsTo(UserLevel::class);
|
||||
}
|
||||
|
||||
|
||||
public function setPriceFromAttribute($value)
|
||||
{
|
||||
$this->attributes['price_from'] = $value ? Util::reFormatNumber($value) : 0;
|
||||
}
|
||||
|
||||
public function getFormattedPriceFrom()
|
||||
{
|
||||
return isset($this->attributes['price_from']) ? Util::formatNumber($this->attributes['price_from']) : "";
|
||||
}
|
||||
|
||||
public function setTradingMarginAttribute($value)
|
||||
{
|
||||
$this->attributes['trading_margin'] = $value ? Util::reFormatNumber($value) : 0;
|
||||
}
|
||||
|
||||
public function getFormattedTradingMargin()
|
||||
{
|
||||
return isset($this->attributes['trading_margin']) ? Util::formatNumber($this->attributes['trading_margin']) : "";
|
||||
}
|
||||
|
||||
public function setCommissionAttribute($value)
|
||||
{
|
||||
$this->attributes['commission'] = $value ? Util::reFormatNumber($value) : 0;
|
||||
}
|
||||
|
||||
public function getFormattedCommission()
|
||||
{
|
||||
return isset($this->attributes['commission']) ? Util::formatNumber($this->attributes['commission']) : "";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue