Add new version in repository
This commit is contained in:
@@ -3,80 +3,81 @@
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Spatie\Image\Manipulations;
|
||||
use Spatie\MediaLibrary\Models\Media;
|
||||
use Spatie\MediaLibrary\HasMedia\HasMedia;
|
||||
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
|
||||
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
|
||||
use Rinvex\Categories\Traits\Categorizable;
|
||||
use Rinvex\Tags\Traits\Taggable;
|
||||
use Fico7489\Laravel\EloquentJoin\Traits\EloquentJoin;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
|
||||
class Article extends Model implements HasMedia
|
||||
{
|
||||
use Categorizable, EloquentJoin, HasMediaTrait, Taggable;
|
||||
use Categorizable, EloquentJoin, InteractsWithMedia, Taggable, SoftDeletes, UserStamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_articles';
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_articles';
|
||||
|
||||
public function article_family()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ArticleFamily');
|
||||
}
|
||||
public function article_nature()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ArticleNature');
|
||||
}
|
||||
|
||||
public function images()
|
||||
{
|
||||
return $this->hasMany('App\Models\Core\Media','model_id')->where('model_type','App\Models\Shop\Article');
|
||||
}
|
||||
public function images()
|
||||
{
|
||||
return $this->hasMany('App\Models\Core\Media', 'model_id')->where('model_type', 'App\Models\Shop\Article');
|
||||
}
|
||||
|
||||
public function image()
|
||||
{
|
||||
return $this->hasOne('App\Models\Core\Media','model_id')->where('model_type','App\Models\Shop\Article');
|
||||
}
|
||||
public function image()
|
||||
{
|
||||
return $this->hasOne('App\Models\Core\Media', 'model_id')->where('model_type', 'App\Models\Shop\Article');
|
||||
}
|
||||
|
||||
public function inventories()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Inventory');
|
||||
}
|
||||
public function inventories()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Inventory');
|
||||
}
|
||||
|
||||
public function invoiceItems()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\InvoiceItem');
|
||||
}
|
||||
public function invoiceItems()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\InvoiceItem');
|
||||
}
|
||||
|
||||
public function prices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Price');
|
||||
}
|
||||
public function prices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Price');
|
||||
}
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
public function product()
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
public function scopeByArticle($query, $id)
|
||||
{
|
||||
return $query->where('shop_articles.id',$id);
|
||||
}
|
||||
public function scopeByArticle($query, $id)
|
||||
{
|
||||
return $query->where('shop_articles.id', $id);
|
||||
}
|
||||
|
||||
public function scopeByCategory($query, $category_id)
|
||||
{
|
||||
public function scopeByCategory($query, $category_id)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
public function scopeByFamily($query, $id)
|
||||
{
|
||||
return $query->where('shop_articles.article_family_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByFamily($query, $id)
|
||||
{
|
||||
return $query->where('shop_articles.article_family_id',$id);
|
||||
}
|
||||
|
||||
public function registerMediaConversions(Media $media = null)
|
||||
{
|
||||
$this->addMediaConversion('thumb')->fit(Manipulations::FIT_CROP, 32, 32);
|
||||
$this->addMediaConversion('mini')->fit(Manipulations::FIT_CROP, 96, 96);
|
||||
$this->addMediaConversion('preview')->fit(Manipulations::FIT_CROP, 160, 160);
|
||||
$this->addMediaConversion('normal')->fit(Manipulations::FIT_CROP, 480, 480);
|
||||
$this->addMediaConversion('zoom')->fit(Manipulations::FIT_CROP, 1200, 1200)->withResponsiveImages();
|
||||
}
|
||||
|
||||
}
|
||||
public function registerMediaConversions(Media $media = null) : void
|
||||
{
|
||||
$this->addMediaConversion('thumb')->fit(Manipulations::FIT_CROP, 32, 32);
|
||||
$this->addMediaConversion('mini')->fit(Manipulations::FIT_CROP, 96, 96);
|
||||
$this->addMediaConversion('preview')->fit(Manipulations::FIT_CROP, 160, 160);
|
||||
$this->addMediaConversion('normal')->fit(Manipulations::FIT_CROP, 480, 480);
|
||||
$this->addMediaConversion('zoom')->fit(Manipulations::FIT_CROP, 1200, 1200)->withResponsiveImages();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ArticleComponent extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_article_components';
|
||||
|
||||
public function Article()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Article');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
class ArticleFamily extends Model
|
||||
{
|
||||
use HasRelationships;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_article_families';
|
||||
|
||||
public function articles()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Article');
|
||||
}
|
||||
|
||||
public function prices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Price');
|
||||
}
|
||||
|
||||
public function packages()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Package');
|
||||
}
|
||||
}
|
||||
22
app/Models/Shop/ArticleNature.php
Normal file
22
app/Models/Shop/ArticleNature.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
class ArticleNature extends Model
|
||||
{
|
||||
use HasRelationships, SoftDeletes, UserStamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_article_natures';
|
||||
|
||||
public function articles()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Article');
|
||||
}
|
||||
}
|
||||
@@ -7,28 +7,28 @@ use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
class ArticlePrice extends Model
|
||||
{
|
||||
use BelongsToThrough;
|
||||
use BelongsToThrough;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_article_prices';
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_article_prices';
|
||||
|
||||
public function price()
|
||||
{
|
||||
return $this->hasOne('App\Models\Price');
|
||||
}
|
||||
public function price()
|
||||
{
|
||||
return $this->hasOne('App\Models\Price');
|
||||
}
|
||||
|
||||
public function article_family()
|
||||
{
|
||||
return $this->belongsTo('App\Models\ArticleFamily');
|
||||
}
|
||||
public function article_family()
|
||||
{
|
||||
return $this->belongsTo('App\Models\ArticleNature');
|
||||
}
|
||||
|
||||
public function scopeByQuantity($query, $quantity)
|
||||
{
|
||||
return $query->orderBy('quantity', 'desc')->where('quantity', '<', $quantity)->first();
|
||||
}
|
||||
public function scopeByQuantity($query, $quantity)
|
||||
{
|
||||
return $query->orderBy('quantity', 'desc')->where('quantity', '<', $quantity)->first();
|
||||
}
|
||||
|
||||
public function scopeByFamily($query, $id)
|
||||
public function scopeByFamily($query, $id)
|
||||
{
|
||||
return $query->where('article_family_value_id', $id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
24
app/Models/Shop/Basket.php
Normal file
24
app/Models/Shop/Basket.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\MediaLibrary\HasMedia\HasMedia;
|
||||
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
|
||||
// use Rinvex\Categories\Traits\Categorizable;
|
||||
use Rinvex\Tags\Traits\Taggable;
|
||||
// use Conner\Tagging\Taggable;
|
||||
use Fico7489\Laravel\EloquentJoin\Traits\EloquentJoin;
|
||||
|
||||
class Category extends Model
|
||||
{
|
||||
use Taggable, HasMediaTrait;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_categories';
|
||||
|
||||
public function Articles()
|
||||
{
|
||||
return $this->morphedByMany('App\Models\Shop\Article', 'categorizable');
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,11 @@
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\MediaLibrary\HasMedia\HasMedia;
|
||||
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
|
||||
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
|
||||
// use Rinvex\Categories\Traits\Categorizable;
|
||||
use Rinvex\Tags\Traits\Taggable;
|
||||
// use Conner\Tagging\Taggable;
|
||||
@@ -12,14 +15,13 @@ use Fico7489\Laravel\EloquentJoin\Traits\EloquentJoin;
|
||||
|
||||
class Category extends Model
|
||||
{
|
||||
use Taggable, HasMediaTrait;
|
||||
use InteractsWithMedia, Taggable;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_categories';
|
||||
protected $table = 'shop_categories';
|
||||
|
||||
public function Articles()
|
||||
{
|
||||
return $this->morphedByMany('App\Models\Shop\Article', 'categorizable');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,21 +6,21 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Customer extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_customers';
|
||||
|
||||
public function Invoices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Invoice');
|
||||
}
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_customers';
|
||||
|
||||
public function Invoices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Invoice');
|
||||
}
|
||||
|
||||
public function Orders()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Order');
|
||||
}
|
||||
public function Orders()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Order');
|
||||
}
|
||||
|
||||
public function User()
|
||||
{
|
||||
return $this->belongsTo('App\User');
|
||||
}
|
||||
}
|
||||
public function User()
|
||||
{
|
||||
return $this->belongsTo('App\User');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CustomerAddress extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function Customer()
|
||||
{
|
||||
@@ -17,5 +17,4 @@ class CustomerAddress extends Model
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Order');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
19
app/Models/Shop/DistributionChannel.php
Normal file
19
app/Models/Shop/DistributionChannel.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
class DistributionChannel extends Model
|
||||
{
|
||||
use HasRelationships;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_article_families';
|
||||
|
||||
public function tariff_generics()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\TariffGeneric');
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Invoice extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $guarded = ['id'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
@@ -23,4 +23,4 @@ class Invoice extends Model
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Customer');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class InvoiceItem extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $guarded = ['id'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
@@ -23,4 +23,4 @@ class InvoiceItem extends Model
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Invoice');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
20
app/Models/Shop/Merchandise.php
Normal file
20
app/Models/Shop/Merchandise.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Rinvex\Tags\Traits\Taggable;
|
||||
|
||||
class Merchandise extends Model
|
||||
{
|
||||
use Taggable;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_merchandises';
|
||||
|
||||
public function Articles()
|
||||
{
|
||||
return $this->morphMany('App\Models\Shop\Article', 'product');
|
||||
}
|
||||
}
|
||||
26
app/Models/Shop/Offer.php
Normal file
26
app/Models/Shop/Offer.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Offer extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_offers';
|
||||
|
||||
public function article()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Article');
|
||||
}
|
||||
|
||||
public function variation()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Variation');
|
||||
}
|
||||
|
||||
public function tariff()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Tariff');
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Order extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $guarded = ['id'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
@@ -23,4 +23,4 @@ class Order extends Model
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\OrderPayment');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class OrderPayment extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $guarded = ['id'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
@@ -15,6 +15,4 @@ class OrderPayment extends Model
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Order');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,21 +6,21 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Package extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_packages';
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_packages';
|
||||
|
||||
public function article_family()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ArticleFamily');
|
||||
}
|
||||
public function article_family()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ArticleNature');
|
||||
}
|
||||
|
||||
public function unities()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Unity');
|
||||
}
|
||||
public function unities()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Unity');
|
||||
}
|
||||
|
||||
public function scopeByArticleFamily($query, $id)
|
||||
{
|
||||
return $query->where('article_family_id', $id);
|
||||
}
|
||||
public function scopeByArticleNature($query, $id)
|
||||
{
|
||||
return $query->where('article_family_id', $id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,54 +2,33 @@
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
class Price extends Model
|
||||
{
|
||||
use HasRelationships;
|
||||
use HasRelationships;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_prices';
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_prices';
|
||||
|
||||
public function article()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Article');
|
||||
}
|
||||
public function article()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Article');
|
||||
}
|
||||
|
||||
public function article_family()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ArticleFamily');
|
||||
}
|
||||
public function article_family()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ArticleNature');
|
||||
}
|
||||
|
||||
public function generic()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\PriceGeneric', 'price_generic_id');
|
||||
}
|
||||
public function scopeByArticle($query, $id)
|
||||
{
|
||||
return $query->where('article_id', $id);
|
||||
}
|
||||
|
||||
public function generic_prices()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function scopeByArticle($query, $id)
|
||||
{
|
||||
return $query->where('article_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByArticleFamily($query, $id)
|
||||
{
|
||||
return $query->where('article_family_id', $id);
|
||||
}
|
||||
|
||||
public function scopeGeneric($query)
|
||||
{
|
||||
return $query->whereNotNull('price_generic_id');
|
||||
}
|
||||
|
||||
public function scopeNotGeneric($query)
|
||||
{
|
||||
return $query->whereNull('price_generic_id');
|
||||
}
|
||||
|
||||
}
|
||||
public function scopeByArticleNature($query, $id)
|
||||
{
|
||||
return $query->where('article_family_id', $id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
class PriceGeneric extends Model
|
||||
{
|
||||
use BelongsToThrough;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_price_generics';
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->hasOne('App\Models\Shop\PriceGenericCategory','id','category_id');
|
||||
}
|
||||
|
||||
public function prices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\PriceGenericValue','price_generic_id')->whereNotNull('price_generic_id');
|
||||
}
|
||||
|
||||
public function priceByUnit()
|
||||
{
|
||||
return $this->hasOne('App\Models\Shop\PriceGenericValue')->orderBy('quantity','asc');
|
||||
}
|
||||
|
||||
public function articles()
|
||||
{
|
||||
return $this->hasManyThrough('App\Models\Shop\Article','App\Models\Shop\Price');
|
||||
}
|
||||
|
||||
public function scopeByCategory($query, $id)
|
||||
{
|
||||
return $query->where('category_id', $id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,18 +6,16 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PriceGenericCategory extends Model
|
||||
{
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_price_generic_categories';
|
||||
|
||||
public function article_family()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ArticleFamily');
|
||||
return $this->belongsTo('App\Models\Shop\ArticleNature');
|
||||
}
|
||||
|
||||
public function price_generics()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\PriceGeneric','category_id');
|
||||
return $this->hasMany('App\Models\Shop\PriceGeneric', 'category_id');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
class PriceGenericValue extends Model
|
||||
{
|
||||
use BelongsToThrough;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_price_generic_values';
|
||||
|
||||
public function price_generic()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\PriceGeneric');
|
||||
}
|
||||
|
||||
public function scopeByPriceGeneric($query, $id)
|
||||
{
|
||||
return $query->where('price_generic_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByQuantity($query, $quantity)
|
||||
{
|
||||
return $query->orderBy('quantity', 'desc')->where('quantity', '<', $quantity)->first();
|
||||
}
|
||||
|
||||
}
|
||||
29
app/Models/Shop/PriceList.php
Normal file
29
app/Models/Shop/PriceList.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
class PriceList extends Model
|
||||
{
|
||||
use BelongsToThrough;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_price_lists';
|
||||
|
||||
public function tariff()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Tariff');
|
||||
}
|
||||
|
||||
public function sale_channel()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\SaleChannel');
|
||||
}
|
||||
|
||||
public function price_list_values()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\PriceListValue');
|
||||
}
|
||||
}
|
||||
32
app/Models/Shop/PriceListValue.php
Normal file
32
app/Models/Shop/PriceListValue.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
class PriceListValue extends Model
|
||||
{
|
||||
use BelongsToThrough, SoftDeletes, Userstamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_price_list_values';
|
||||
|
||||
public function price_list()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\PriceList');
|
||||
}
|
||||
|
||||
public function scopeByPriceList($query, $id)
|
||||
{
|
||||
return $query->where('price_list_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByQuantity($query, $quantity)
|
||||
{
|
||||
return $query->orderBy('quantity', 'desc')->where('quantity', '<', $quantity)->first();
|
||||
}
|
||||
}
|
||||
11
app/Models/Shop/SaleChannel.php
Normal file
11
app/Models/Shop/SaleChannel.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SaleChannel extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_sale_channels';
|
||||
}
|
||||
29
app/Models/Shop/Shelve.php
Normal file
29
app/Models/Shop/Shelve.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
class ArticleNature extends Model
|
||||
{
|
||||
use HasRelationships;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_article_families';
|
||||
|
||||
public function articles()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Article');
|
||||
}
|
||||
|
||||
public function prices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Price');
|
||||
}
|
||||
|
||||
public function packages()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Package');
|
||||
}
|
||||
}
|
||||
@@ -6,21 +6,20 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Tag extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function group()
|
||||
{
|
||||
return $this->hasOne('App\Models\Shop\TagGroup','id','tag_group_id');
|
||||
}
|
||||
public function group()
|
||||
{
|
||||
return $this->hasOne('App\Models\Shop\TagGroup', 'id', 'tag_group_id');
|
||||
}
|
||||
|
||||
public function scopeByGroup($query, $id)
|
||||
{
|
||||
return $query->where('tag_group_id', $id);
|
||||
}
|
||||
|
||||
public function getNameAttribute($value)
|
||||
{
|
||||
return json_decode($value)->fr;
|
||||
}
|
||||
public function scopeByGroup($query, $id)
|
||||
{
|
||||
return $query->where('tag_group_id', $id);
|
||||
}
|
||||
|
||||
public function getNameAttribute($value)
|
||||
{
|
||||
return json_decode($value)->fr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,17 +6,17 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TagGroup extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'tag_groups';
|
||||
public $timestamps = false;
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'tag_groups';
|
||||
public $timestamps = false;
|
||||
|
||||
public function tags()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Tag');
|
||||
}
|
||||
public function tags()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Tag');
|
||||
}
|
||||
|
||||
public function article_family()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ArticleFamily');
|
||||
}
|
||||
public function article_family()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ArticleNature');
|
||||
}
|
||||
}
|
||||
|
||||
30
app/Models/Shop/Tariff.php
Normal file
30
app/Models/Shop/Tariff.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
class Tariff extends Model
|
||||
{
|
||||
use HasRelationships;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_tariffs';
|
||||
|
||||
public function sale_channel()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\SaleChannel');
|
||||
}
|
||||
|
||||
public function tariff_unity()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\TariffUnity');
|
||||
}
|
||||
|
||||
public function price_lists()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\PriceList');
|
||||
}
|
||||
}
|
||||
16
app/Models/Shop/TariffUnity.php
Normal file
16
app/Models/Shop/TariffUnity.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TariffUnity extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_tariff_unities';
|
||||
|
||||
public function tariffs()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Tariff');
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,11 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Tax extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_taxes';
|
||||
|
||||
public function price()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\ArticlePrice','id','tax_id');
|
||||
return $this->hasMany('App\Models\Shop\ArticlePrice', 'id', 'tax_id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,38 +9,41 @@ use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
class Unity extends Model
|
||||
{
|
||||
use BelongsToThrough, softDeletes;
|
||||
use BelongsToThrough, softDeletes;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_unities';
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_unities';
|
||||
|
||||
public function package()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Package');
|
||||
}
|
||||
public function package()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Package');
|
||||
}
|
||||
|
||||
public function article_family()
|
||||
{
|
||||
return $this->belongsToThrough('App\Models\Shop\ArticleFamily', 'App\Models\Shop\Package', null, '', ['App\Models\Shop\ArticleFamily' => 'article_family_id', 'App\Models\Shop\Package' => 'package_id']);
|
||||
}
|
||||
public function article_family()
|
||||
{
|
||||
return $this->belongsToThrough('App\Models\Shop\ArticleNature', 'App\Models\Shop\Package', null, '', ['App\Models\Shop\ArticleNature' => 'article_family_id', 'App\Models\Shop\Package' => 'package_id']);
|
||||
}
|
||||
|
||||
public function scopeByPackage($query, $id)
|
||||
{
|
||||
return $query->where('package_id', $id);
|
||||
}
|
||||
public function scopeByPackage($query, $id)
|
||||
{
|
||||
return $query->where('package_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByArticleFamily($query, $id)
|
||||
{
|
||||
return $query->whereHas('package', function ($query) use ($id) {
|
||||
$query->byArticleFamily($id);
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeActive($query, $active = 1)
|
||||
{
|
||||
return $query->whereHas('third_party', function ($query) use ($active) {
|
||||
$query->active($active);
|
||||
});
|
||||
}
|
||||
public function scopeByArticleNature($query, $id)
|
||||
{
|
||||
return $query->whereHas(
|
||||
'package', function ($query) use ($id) {
|
||||
$query->byArticleNature($id);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function scopeActive($query, $active = 1)
|
||||
{
|
||||
return $query->whereHas(
|
||||
'third_party', function ($query) use ($active) {
|
||||
$query->active($active);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
21
app/Models/Shop/Variation.php
Normal file
21
app/Models/Shop/Variation.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Variation extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_variations';
|
||||
|
||||
public function package()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Package');
|
||||
}
|
||||
|
||||
public function unity()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Unity');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user