[WIP] Refactor architecture, models
This commit is contained in:
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user