Synchro back-office, fix on tariffs
This commit is contained in:
@@ -10,13 +10,14 @@ use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
|
||||
use BeyondCode\Comments\Traits\HasComments;
|
||||
use Rinvex\Categories\Traits\Categorizable;
|
||||
use Rinvex\Tags\Traits\Taggable;
|
||||
use Kirschbaum\PowerJoins\PowerJoins;
|
||||
use Fico7489\Laravel\EloquentJoin\Traits\EloquentJoin;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
|
||||
use App\Traits\HasComments;
|
||||
|
||||
class Article extends Model implements HasMedia
|
||||
{
|
||||
use Categorizable, EloquentJoin, HasComments, InteractsWithMedia, Powerjoins, Taggable, SoftDeletes, UserStamps;
|
||||
@@ -44,6 +45,11 @@ class Article extends Model implements HasMedia
|
||||
return $this->hasMany(InvoiceItem::class);
|
||||
}
|
||||
|
||||
public function offers()
|
||||
{
|
||||
return $this->hasMany(Offer::class);
|
||||
}
|
||||
|
||||
public function prices()
|
||||
{
|
||||
return $this->hasMany(Price::class);
|
||||
@@ -66,6 +72,9 @@ class Article extends Model implements HasMedia
|
||||
|
||||
public function scopeByCategory($query, $category_id)
|
||||
{
|
||||
return $query->whereHas('categories', function ($query) use ($category_id) {
|
||||
$query->where('id', $category_id);
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeByArticleNature($query, $id)
|
||||
@@ -83,6 +92,11 @@ class Article extends Model implements HasMedia
|
||||
return $query->where($this->table . '.product_id', $model_id);
|
||||
}
|
||||
|
||||
public function scopeWithOffers($query)
|
||||
{
|
||||
return $query->has('Offers');
|
||||
}
|
||||
|
||||
public function registerMediaConversions(Media $media = null) : void
|
||||
{
|
||||
$this->addMediaConversion('thumb')->fit(Manipulations::FIT_CROP, 32, 32);
|
||||
|
||||
@@ -35,4 +35,9 @@ class Category extends Model
|
||||
return $this->belongsTo(app('rinvex.categories.category'),'category_id');
|
||||
}
|
||||
|
||||
public function scopeByCategory($query, $category_id)
|
||||
{
|
||||
return $query->where('category_id', $category_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@ namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use BeyondCode\Comments\Traits\HasComments;
|
||||
use App\Traits\HasComments;
|
||||
|
||||
class Offer extends Model
|
||||
{
|
||||
use HasComments;
|
||||
@@ -17,6 +18,11 @@ class Offer extends Model
|
||||
return $this->belongsTo(Article::class);
|
||||
}
|
||||
|
||||
public function categories()
|
||||
{
|
||||
return $this->article->categories();
|
||||
}
|
||||
|
||||
public function variation()
|
||||
{
|
||||
return $this->belongsTo(Variation::class);
|
||||
@@ -26,4 +32,26 @@ class Offer extends Model
|
||||
{
|
||||
return $this->belongsTo(Tariff::class);
|
||||
}
|
||||
|
||||
public function scopeByArticle($query, $id)
|
||||
{
|
||||
return $query->where('article_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByCategory($query, $category_id)
|
||||
{
|
||||
return $query->whereHas('article.categories', function ($query) use ($category_id) {
|
||||
$query->where('category_id', $category_id);
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeByStatus($query, $id)
|
||||
{
|
||||
return $query->where('status_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByVariation($query, $id)
|
||||
{
|
||||
return $query->where('variation_id', $id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,10 @@ namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use BeyondCode\Comments\Traits\HasComments;
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
use App\Traits\HasComments;
|
||||
|
||||
class PriceList extends Model
|
||||
{
|
||||
use BelongsToThrough, HasComments;
|
||||
|
||||
@@ -5,9 +5,10 @@ namespace App\Models\Shop;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
use BeyondCode\Comments\Traits\HasComments;
|
||||
use Kirschbaum\PowerJoins\PowerJoins;
|
||||
|
||||
use App\Traits\HasComments;
|
||||
|
||||
class Tariff extends Model
|
||||
{
|
||||
use HasComments, HasRelationships, PowerJoins;
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use BeyondCode\Comments\Traits\HasComments;
|
||||
use App\Traits\HasComments;
|
||||
class Variation extends Model
|
||||
{
|
||||
use HasComments;
|
||||
|
||||
Reference in New Issue
Block a user