Add display articles & categories, raw mode
This commit is contained in:
12
app/Models/Core/Media.php
Normal file
12
app/Models/Core/Media.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Core;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Media extends Model
|
||||
{
|
||||
protected $table = 'media';
|
||||
|
||||
}
|
||||
@@ -26,9 +26,14 @@ class Article extends Model implements HasMedia
|
||||
return $this->hasMany('App\Models\Shop\ArticleAttribute');
|
||||
}
|
||||
|
||||
public function prices()
|
||||
public function images()
|
||||
{
|
||||
return $this->hasManyThrough('App\Models\Shop\ArticlePrice','App\Models\Shop\ArticleAttribute');
|
||||
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 inventories()
|
||||
@@ -41,6 +46,11 @@ class Article extends Model implements HasMedia
|
||||
return $this->hasMany('App\Models\Shop\InvoiceItem');
|
||||
}
|
||||
|
||||
public function prices()
|
||||
{
|
||||
return $this->hasManyThrough('App\Models\Shop\ArticlePrice','App\Models\Shop\ArticleAttribute');
|
||||
}
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->morphTo();
|
||||
|
||||
Reference in New Issue
Block a user