Update with new price management
This commit is contained in:
@@ -3,9 +3,12 @@
|
||||
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';
|
||||
|
||||
@@ -13,4 +16,14 @@ class ArticleFamily extends Model
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Article');
|
||||
}
|
||||
|
||||
public function prices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Price');
|
||||
}
|
||||
|
||||
public function unities()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Unity');
|
||||
}
|
||||
}
|
||||
@@ -17,9 +17,9 @@ class ArticlePrice extends Model
|
||||
return $this->hasOne('App\Models\Price');
|
||||
}
|
||||
|
||||
public function priceFamilyValue()
|
||||
public function article_family()
|
||||
{
|
||||
return $this->belongsTo('App\Models\PriceFamilyValue');
|
||||
return $this->belongsTo('App\Models\ArticleFamily');
|
||||
}
|
||||
|
||||
public function scopeByQuantity($query, $quantity)
|
||||
@@ -27,8 +27,8 @@ class ArticlePrice extends Model
|
||||
return $query->orderBy('quantity', 'desc')->where('quantity', '<', $quantity)->first();
|
||||
}
|
||||
|
||||
public function scopeByPriceFamilyValue($query, $id)
|
||||
public function scopeByFamily($query, $id)
|
||||
{
|
||||
return $query->where('price_family_value_id', $id);
|
||||
return $query->where('article_family_value_id', $id);
|
||||
}
|
||||
}
|
||||
@@ -17,9 +17,9 @@ class Price extends Model
|
||||
return $this->belongsTo('App\Models\Shop\Article');
|
||||
}
|
||||
|
||||
public function price_family()
|
||||
public function article_family()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\PriceFamily');
|
||||
return $this->belongsTo('App\Models\Shop\ArticleFamily');
|
||||
}
|
||||
|
||||
public function generic()
|
||||
@@ -29,7 +29,7 @@ class Price extends Model
|
||||
|
||||
public function generic_prices()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function scopeByArticle($query, $id)
|
||||
@@ -37,9 +37,9 @@ class Price extends Model
|
||||
return $query->where('article_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByPriceFamily($query, $id)
|
||||
public function scopeByArticleFamily($query, $id)
|
||||
{
|
||||
return $query->where('price_family_id', $id);
|
||||
return $query->where('article_family_id', $id);
|
||||
}
|
||||
|
||||
public function scopeGeneric($query)
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
class PriceFamily extends Model
|
||||
{
|
||||
use HasRelationships;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_price_families';
|
||||
|
||||
public function prices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Price');
|
||||
}
|
||||
|
||||
public function values()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\PriceFamilyValue');
|
||||
}
|
||||
|
||||
public function articles()
|
||||
{
|
||||
return $this->hasManyThrough('App\Models\Shop\Article','App\Models\Shop\Price');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PriceFamilyValue extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_price_family_values';
|
||||
|
||||
public function price_family()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\PriceFamily');
|
||||
}
|
||||
|
||||
public function scopeByFamily($query, $id)
|
||||
{
|
||||
return $query->where('price_family_id');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,8 +6,16 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Unity extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_unities';
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_unities';
|
||||
|
||||
public function article_family()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ArticleFamily');
|
||||
}
|
||||
|
||||
public function scopeByFamily($query, $id)
|
||||
{
|
||||
return $query->where('article_family_id');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user