Mise à jour

This commit is contained in:
Ludovic CANDELLIER
2021-03-21 23:26:53 +01:00
parent c025dbb385
commit 083d358fbd
78 changed files with 1003 additions and 716 deletions

View File

@@ -22,9 +22,14 @@ class Price extends Model
return $this->belongsTo('App\Models\Shop\PriceFamily');
}
public function price()
public function generic()
{
return $this->morphTo();
return $this->belongsTo('App\Models\Shop\PriceGeneric', 'price_generic_id');
}
public function generic_prices()
{
}
public function scopeByArticle($query, $id)
@@ -37,4 +42,14 @@ class Price extends Model
return $query->where('price_family_id', $id);
}
public function scopeGeneric($query)
{
return $query->whereNotNull('price_generic_id');
}
public function scopeNotGeneric($query)
{
return $query->whereNull('price_generic_id');
}
}

View File

@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model;
class PriceFamilyValue extends Model
{
protected $guarded = ['id'];
protected $table = 'shop_price_familiy_values';
protected $table = 'shop_price_family_values';
public function price_family()
{

View File

@@ -7,39 +7,34 @@ use Znck\Eloquent\Traits\BelongsToThrough;
class PriceGeneric extends Model
{
use BelongsToThrough;
use BelongsToThrough;
protected $guarded = ['id'];
protected $table = 'shop_price_generics';
protected $guarded = ['id'];
protected $table = 'shop_price_generics';
public function category()
{
return $this->hasOne('App\Models\Shop\PriceGenericCategory','id','category_id');
}
public function category()
{
return $this->hasOne('App\Models\Shop\PriceGenericCategory','id','category_id');
}
public function prices()
{
return $this->hasMany('App\Models\Shop\Price','price_id')->where('price_type','App\Models\Shop\PriceGeneric');
return $this->hasMany('App\Models\Shop\PriceGenericValue','price_generic_id')->whereNotNull('price_generic_id');
}
public function values()
{
return $this->hasMany('App\Models\Shop\PriceGenericValue');
}
public function priceByUnit()
{
return $this->hasOne('App\Models\Shop\PriceGenericValue')->orderBy('quantity','asc');
}
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 articles()
{
return $this->hasManyThrough('App\Models\Shop\Article','App\Models\Shop\Price');
}
public function scopeByCategory($query, $id)
{
return $query->where('category_id', $id);
}
public function scopeByCategory($query, $id)
{
return $query->where('category_id', $id);
}
}

View File

@@ -6,21 +6,21 @@ use Illuminate\Database\Eloquent\Model;
class Tag extends Model
{
protected $guarded = ['id'];
protected $guarded = ['id'];
public function group()
{
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 scopeByGroup($query, $id)
{
return $query->where('tag_group_id', $id);
}
public function getNameAttribute($value)
{
return json_decode($value)->fr;
}
public function getNameAttribute($value)
{
return json_decode($value)->fr;
}
}

View File

@@ -6,12 +6,11 @@ use Illuminate\Database\Eloquent\Model;
class TagGroup extends Model
{
protected $guarded = ['id'];
protected $table = 'tag_groups';
protected $guarded = ['id'];
protected $table = 'tag_groups';
public function tags()
{
return $this->hasMany('App\Models\Shop\Tag');
}
{
return $this->hasMany('App\Models\Shop\Tag');
}
}

13
app/Models/Shop/Unity.php Normal file
View File

@@ -0,0 +1,13 @@
<?php
namespace App\Models\Shop;
use Illuminate\Database\Eloquent\Model;
class Unity extends Model
{
protected $guarded = ['id'];
protected $table = 'shop_unities';
}