Homparty dev
This commit is contained in:
parent
9252094a04
commit
ac0d5b781e
60 changed files with 3443 additions and 293 deletions
|
|
@ -51,6 +51,12 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $token
|
||||
* @property bool|null $token_active
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\HomepartyUser[] $homeparty_guests
|
||||
* @property-read int|null $homeparty_guests_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereToken($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereTokenActive($value)
|
||||
*/
|
||||
class Homeparty extends Model
|
||||
{
|
||||
|
|
@ -62,13 +68,18 @@ class Homeparty extends Model
|
|||
'status' => 'int',
|
||||
'order_to' => 'bool',
|
||||
'active' => 'bool',
|
||||
'default' => 'bool'
|
||||
'default' => 'bool',
|
||||
'token_active' => 'bool'
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'date'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'token'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'auth_user_id',
|
||||
'date',
|
||||
|
|
@ -80,7 +91,9 @@ class Homeparty extends Model
|
|||
'status',
|
||||
'order_to',
|
||||
'active',
|
||||
'default'
|
||||
'default',
|
||||
'token',
|
||||
'token_active',
|
||||
];
|
||||
|
||||
public function auth_user()
|
||||
|
|
@ -116,5 +129,9 @@ class Homeparty extends Model
|
|||
{
|
||||
$this->attributes['date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
|
||||
public function getTokenLink(){
|
||||
return url('homeparty/'.$this->token);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Services\HomepartyUserCart;
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
|
@ -102,10 +103,15 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Query\Builder|\App\Models\HomepartyUser withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\HomepartyUser withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\HomepartyUserOrderItem[] $homeparty_user_order_items
|
||||
* @property-read int|null $homeparty_user_order_items_count
|
||||
*/
|
||||
class HomepartyUser extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $userCart = null;
|
||||
|
||||
protected $table = 'homeparty_users';
|
||||
|
||||
protected $casts = [
|
||||
|
|
@ -117,16 +123,12 @@ class HomepartyUser extends Model
|
|||
'shipping_country_id' => 'int',
|
||||
'has_buyed' => 'bool',
|
||||
'subscribed' => 'bool',
|
||||
'token_active' => 'bool'
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'user_deleted_at'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'token'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'homeparty_id',
|
||||
|
|
@ -157,8 +159,6 @@ class HomepartyUser extends Model
|
|||
'shipping_email',
|
||||
'has_buyed',
|
||||
'subscribed',
|
||||
'token',
|
||||
'token_active',
|
||||
'notice',
|
||||
'mode',
|
||||
'user_deleted_at'
|
||||
|
|
@ -184,9 +184,15 @@ class HomepartyUser extends Model
|
|||
return $this->belongsTo('App\Models\Country','shipping_country_id');
|
||||
}
|
||||
|
||||
public function getTokenLink(){
|
||||
return url('homeparty/'.$this->token);
|
||||
public function homeparty_user_order_items(){
|
||||
return $this->hasMany('App\Models\HomepartyUserOrderItem','homeparty_user_id');
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function isAddress(){
|
||||
if($this->billing_firstname !== null){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
174
app/Models/HomepartyUserOrderItem.php
Normal file
174
app/Models/HomepartyUserOrderItem.php
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class HomepartyUserOrderItem
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $homeparty_id
|
||||
* @property int $homeparty_user_id
|
||||
* @property int $product_id
|
||||
* @property int $qty
|
||||
* @property float $price
|
||||
* @property float $price_net
|
||||
* @property float $tax_rate
|
||||
* @property int $points
|
||||
* @property float $margin
|
||||
* @property float $ek-price
|
||||
* @property string $slug
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property Homeparty $homeparty
|
||||
* @property HomepartyUser $homeparty_user
|
||||
* @property Product $product
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereEkPrice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereHomepartyId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereHomepartyUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereMargin($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem wherePoints($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem wherePrice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem wherePriceNet($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereProductId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereQty($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereTaxRate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class HomepartyUserOrderItem extends Model
|
||||
{
|
||||
protected $table = 'homeparty_user_order_items';
|
||||
|
||||
protected $casts = [
|
||||
'homeparty_id' => 'int',
|
||||
'homeparty_user_id' => 'int',
|
||||
'product_id' => 'int',
|
||||
'qty' => 'int',
|
||||
'price' => 'float',
|
||||
'price_net' => 'float',
|
||||
'tax_rate' => 'float',
|
||||
'points' => 'int',
|
||||
'margin' => 'float',
|
||||
'ek-price' => 'float'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'homeparty_id',
|
||||
'homeparty_user_id',
|
||||
'product_id',
|
||||
'qty',
|
||||
'price',
|
||||
'price_net',
|
||||
'tax_rate',
|
||||
'points',
|
||||
'margin',
|
||||
'ek-price',
|
||||
'slug'
|
||||
];
|
||||
|
||||
public function homeparty()
|
||||
{
|
||||
return $this->belongsTo(Homeparty::class);
|
||||
}
|
||||
|
||||
public function homeparty_user()
|
||||
{
|
||||
return $this->belongsTo(HomepartyUser::class);
|
||||
}
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
|
||||
public function getFormattedPrice()
|
||||
{
|
||||
return formatNumber($this->attributes['price']);
|
||||
}
|
||||
|
||||
public function getFormattedTotalPrice()
|
||||
{
|
||||
return formatNumber($this->attributes['price'] * $this->attributes['qty']);
|
||||
}
|
||||
|
||||
public function getFormattedPriceNet()
|
||||
{
|
||||
return formatNumber($this->attributes['price_net']);
|
||||
}
|
||||
|
||||
public function getFormattedTotalPriceNet()
|
||||
{
|
||||
return formatNumber($this->attributes['price_net'] * $this->attributes['qty']);
|
||||
}
|
||||
|
||||
public function getFormattedEKPrice()
|
||||
{
|
||||
return formatNumber($this->attributes['ek-price']);
|
||||
}
|
||||
|
||||
public function getFormattedTotalEKPrice()
|
||||
{
|
||||
return formatNumber($this->attributes['ek-price'] * $this->attributes['qty']);
|
||||
}
|
||||
|
||||
public function getFormattedIncomePrice()
|
||||
{
|
||||
return formatNumber($this->attributes['price'] - $this->attributes['ek-price']);
|
||||
}
|
||||
|
||||
public function getFormattedTotalIncomePrice()
|
||||
{
|
||||
return formatNumber(($this->attributes['price'] - $this->attributes['ek-price']) * $this->attributes['qty']);
|
||||
}
|
||||
|
||||
public function getFormattedTotalPoints()
|
||||
{
|
||||
return formatNumber($this->attributes['points'] * $this->attributes['qty'], 0);
|
||||
}
|
||||
|
||||
public function getTotalPrice()
|
||||
{
|
||||
return (float) ($this->attributes['price'] * $this->attributes['qty']);
|
||||
}
|
||||
|
||||
|
||||
public function getTotalPoints()
|
||||
{
|
||||
return ($this->attributes['points'] * $this->attributes['qty']);
|
||||
}
|
||||
|
||||
public function geTotalPriceNet()
|
||||
{
|
||||
return (float) ($this->attributes['price_net'] * $this->attributes['qty']);
|
||||
}
|
||||
|
||||
public function geTotalEKPrice()
|
||||
{
|
||||
return (float) ($this->attributes['ek-price'] * $this->attributes['qty']);
|
||||
}
|
||||
|
||||
public function getIncomePrice()
|
||||
{
|
||||
return (float) ($this->attributes['price'] - $this->attributes['ek-price']);
|
||||
}
|
||||
|
||||
public function geTotalIncomePrice()
|
||||
{
|
||||
return (float) (($this->attributes['price'] - $this->attributes['ek-price']) * $this->attributes['qty']);
|
||||
}
|
||||
}
|
||||
|
||||
80
app/Models/Ingredient.php
Normal file
80
app/Models/Ingredient.php
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Ingredient
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $trans_name
|
||||
* @property string $inci
|
||||
* @property string $trans_inci
|
||||
* @property string $effect
|
||||
* @property string $trans_effect
|
||||
* @property bool $active
|
||||
* @property int $pos
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property Collection|Product[] $products
|
||||
* @package App\Models
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductIngredient[] $product_ingredients
|
||||
* @property-read int|null $product_ingredients_count
|
||||
* @property-read int|null $products_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereEffect($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereInci($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereTransEffect($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereTransInci($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereTransName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Ingredient extends Model
|
||||
{
|
||||
protected $table = 'ingredients';
|
||||
|
||||
protected $casts = [
|
||||
'active' => 'bool',
|
||||
'pos' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'trans_name',
|
||||
'inci',
|
||||
'trans_inci',
|
||||
'effect',
|
||||
'trans_effect',
|
||||
'active',
|
||||
'pos'
|
||||
];
|
||||
|
||||
public function products()
|
||||
{
|
||||
return $this->belongsToMany(Product::class, 'product_ingredients')
|
||||
->withPivot('id')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function product_ingredients()
|
||||
{
|
||||
return $this->hasMany(ProductIngredient::class, 'product_ingredients', 'id');
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -105,6 +105,9 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereWpNumber($value)
|
||||
* @property bool|null $shipping_addon
|
||||
* @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
|
||||
*/
|
||||
class Product extends Model
|
||||
{
|
||||
|
|
@ -230,6 +233,20 @@ class Product extends Model
|
|||
return $this->hasMany(CountryPrice::class, 'product_id');
|
||||
}
|
||||
|
||||
|
||||
public function p_ingredients()
|
||||
{
|
||||
return $this->belongsToMany(Ingredient::class, 'product_ingredients')
|
||||
->withPivot('id')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function product_ingredients()
|
||||
{
|
||||
return $this->hasMany(ProductIngredient::class, 'product_ingredients', 'id');
|
||||
}
|
||||
|
||||
|
||||
public function getActionName($id = 0){
|
||||
if(isset($this->actions[$id])){
|
||||
return $this->actions[$id];
|
||||
|
|
|
|||
56
app/Models/ProductIngredient.php
Normal file
56
app/Models/ProductIngredient.php
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class ProductIngredient
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $product_id
|
||||
* @property int $ingredient_id
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property Ingredient $ingredient
|
||||
* @property Product $product
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient whereIngredientId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient whereProductId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ProductIngredient extends Model
|
||||
{
|
||||
protected $table = 'product_ingredients';
|
||||
|
||||
protected $casts = [
|
||||
'product_id' => 'int',
|
||||
'ingredient_id' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'product_id',
|
||||
'ingredient_id'
|
||||
];
|
||||
|
||||
public function ingredient()
|
||||
{
|
||||
return $this->belongsTo(Ingredient::class, 'ingredient_id');
|
||||
}
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo(Product::class, 'product_id');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue