Fixes for deliveries vs sale_channels
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
@@ -10,12 +11,12 @@ use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
|
||||
// use Rinvex\Categories\Traits\Categorizable;
|
||||
use Rinvex\Tags\Traits\Taggable;
|
||||
// use Conner\Tagging\Taggable;
|
||||
use Fico7489\Laravel\EloquentJoin\Traits\EloquentJoin;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
|
||||
class Category extends Model
|
||||
{
|
||||
use InteractsWithMedia, Taggable;
|
||||
use InteractsWithMedia, SoftDeletes, Taggable, Userstamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_categories';
|
||||
@@ -25,6 +26,11 @@ class Category extends Model
|
||||
return $this->morphedByMany(Article::class, 'categorizable');
|
||||
}
|
||||
|
||||
public function ArticlesTagged()
|
||||
{
|
||||
return $this->tags->articles;
|
||||
}
|
||||
|
||||
public function Shelves()
|
||||
{
|
||||
return $this->morphedByMany(Category::class, 'categorizable');
|
||||
|
||||
@@ -19,9 +19,14 @@ class Customer extends Model
|
||||
return $this->hasMany(Invoice::class);
|
||||
}
|
||||
|
||||
public function Delivery()
|
||||
public function customer_deliveries()
|
||||
{
|
||||
return $this->belongsTo(Delivery::class);
|
||||
return $this->hasMany(CustomerDelivery::class);
|
||||
}
|
||||
|
||||
public function deliveries()
|
||||
{
|
||||
return $this->hasManyThrough(Delivery::class, CustomerDelivery::class);
|
||||
}
|
||||
|
||||
public function Orders()
|
||||
|
||||
31
app/Models/Shop/CustomerDelivery.php
Normal file
31
app/Models/Shop/CustomerDelivery.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CustomerDelivery extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_customer_deliveries';
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function delivery()
|
||||
{
|
||||
return $this->belongsTo(Delivery::class);
|
||||
}
|
||||
|
||||
public function scopeByCustomer($query, $customer_id)
|
||||
{
|
||||
return $query->where($this->table . '.customer_id', $customer_id);
|
||||
}
|
||||
|
||||
public function scopeByDelivery($query, $customer_id)
|
||||
{
|
||||
return $query->where($this->table . '.delivery_id', $customer_id);
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,12 @@ namespace App\Models\Shop;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Spatie\Translatable\HasTranslations;
|
||||
use Rinvex\Tags\Models\Tag as parentTag;
|
||||
|
||||
use App\Models\Botanic\Specie;
|
||||
use App\Models\Botanic\Variety;
|
||||
|
||||
class Tag extends Model
|
||||
class Tag extends parentTag
|
||||
{
|
||||
use HasTranslations;
|
||||
|
||||
@@ -27,6 +29,11 @@ class Tag extends Model
|
||||
return $this->morphedByMany(Article::class, 'taggable');
|
||||
}
|
||||
|
||||
public function categories()
|
||||
{
|
||||
return $this->morphedByMany(Category::class, 'taggable');
|
||||
}
|
||||
|
||||
public function group()
|
||||
{
|
||||
return $this->hasOne(TagGroup::class, 'id', 'tag_group_id');
|
||||
|
||||
Reference in New Issue
Block a user