|
@@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
|
|
|
+use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\DB;
|
|
@@ -114,20 +115,23 @@ class Product extends Model
|
|
|
return $this->belongsToMany(Order::class, 'products_sku', 'order_id', 'product_id');
|
|
return $this->belongsToMany(Order::class, 'products_sku', 'order_id', 'product_id');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function products_sku(): HasOne
|
|
|
|
|
|
|
+
|
|
|
|
|
+ public function maf_orders(): HasMany
|
|
|
{
|
|
{
|
|
|
- return $this->hasOne(ProductSku::class, 'product_id', 'id');
|
|
|
|
|
|
|
+ return $this->hasMany(MafOrder::class, 'product_id', 'id');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function hasRelations(): bool
|
|
public function hasRelations(): bool
|
|
|
{
|
|
{
|
|
|
- if($this->products_sku && ($this->products_sku->count() > 0)) {
|
|
|
|
|
|
|
+ if($this->maf_orders && ($this->maf_orders->count() > 0)) {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if($this->orders && ($this->orders->count() > 0)) {
|
|
if($this->orders && ($this->orders->count() > 0)) {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|