[WIP] Refactor architecture, models
This commit is contained in:
@@ -11,7 +11,7 @@ class Specie extends Model
|
||||
|
||||
public function Genre()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Botanic\Family');
|
||||
return $this->belongsTo('App\Models\Botanic\Genre');
|
||||
}
|
||||
|
||||
public function Varieties()
|
||||
|
||||
@@ -5,12 +5,20 @@ namespace App\Models\Shop;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Rinvex\Categories\Traits\Categorizable;
|
||||
use Conner\Tagging\Taggable;
|
||||
|
||||
class Product extends Model
|
||||
class Article extends Model
|
||||
{
|
||||
use Categorizable;
|
||||
use Taggable;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_products';
|
||||
protected $table = 'shop_articles';
|
||||
|
||||
public function Family()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Family');
|
||||
}
|
||||
|
||||
public function Inventories()
|
||||
{
|
||||
@@ -19,17 +27,17 @@ class Product extends Model
|
||||
|
||||
public function Prices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\ProductPrice');
|
||||
return $this->hasMany('App\Models\Shop\ArticlePrice');
|
||||
}
|
||||
|
||||
public function ProductAttributes()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\ProductAttribute');
|
||||
return $this->hasMany('App\Models\Shop\ArticleAttribute');
|
||||
}
|
||||
|
||||
public function Categories()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\CategoryProduct');
|
||||
return $this->hasMany('App\Models\Shop\ArticleCategory');
|
||||
}
|
||||
|
||||
public function InvoiceItems()
|
||||
@@ -4,15 +4,15 @@ namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ProductAttribute extends Model
|
||||
class ArticleAttribute extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function Product()
|
||||
public function Article()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Product');
|
||||
return $this->belongsTo('App\Models\Shop\Article');
|
||||
}
|
||||
}
|
||||
31
app/Models/Shop/ArticleCategory.php
Normal file
31
app/Models/Shop/ArticleCategory.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ArticleCategory extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_article_categories';
|
||||
|
||||
public function Article()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Article');
|
||||
}
|
||||
|
||||
public function Category()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Category');
|
||||
}
|
||||
|
||||
public function scopeByArticle($query, $id)
|
||||
{
|
||||
return $query->where('article_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByCategory($query, $id)
|
||||
{
|
||||
return $query->where('category_id', $id);
|
||||
}
|
||||
}
|
||||
19
app/Models/Shop/ArticleFamily.php
Normal file
19
app/Models/Shop/ArticleFamily.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ArticleFamily extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_article_families';
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function Articles()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Article');
|
||||
}
|
||||
}
|
||||
26
app/Models/Shop/ArticlePrice.php
Normal file
26
app/Models/Shop/ArticlePrice.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ArticlePrice extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function Article()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Article');
|
||||
}
|
||||
|
||||
public function ArticleAttribute()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ArticleAttribute');
|
||||
}
|
||||
|
||||
public function scopeByArticle($query, $id)
|
||||
{
|
||||
return $query->where('article_id', $id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,11 +5,12 @@ namespace App\Models\Shop;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Rinvex\Categories\Traits\Categorizable;
|
||||
use Conner\Tagging\Taggable;
|
||||
|
||||
class Section extends Model
|
||||
class Category extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_sections';
|
||||
protected $table = 'shop_categories';
|
||||
|
||||
public function Category()
|
||||
{
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ProductPrice extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function Product()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Product');
|
||||
}
|
||||
|
||||
public function ProductAttribute()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ProductAttribute');
|
||||
}
|
||||
|
||||
public function scopeByProduct($query, $id)
|
||||
{
|
||||
return $query->where('product_id', $id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ProductSection extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_product_sections';
|
||||
|
||||
public function Product()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Product');
|
||||
}
|
||||
|
||||
public function Section()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Product');
|
||||
}
|
||||
|
||||
public function scopeByProduct($query, $id)
|
||||
{
|
||||
return $query->where('product_id', $id);
|
||||
}
|
||||
|
||||
public function scopeBySection($query, $id)
|
||||
{
|
||||
return $query->where('section_id', $id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user