File: /home/royaltuning/public_html/public/backoffice.royaltuning.hu/app/Models/ShopCategoryMapping.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ShopCategoryMapping extends Model
{
protected $fillable = [
'source_shop_id',
'source_woo_category_id',
'target_shop_id',
'target_woo_category_id',
];
public function sourceShop()
{
return $this->belongsTo(Shop::class, 'source_shop_id');
}
public function targetShop()
{
return $this->belongsTo(Shop::class, 'target_shop_id');
}
public function sourceCategory()
{
return $this->belongsTo(
ShopCategory::class,
'source_woo_category_id',
'woo_category_id'
)->whereColumn('shop_categories.shop_id', 'shop_category_mappings.source_shop_id');
}
public function targetCategory()
{
return $this->belongsTo(
ShopCategory::class,
'target_woo_category_id',
'woo_category_id'
)->whereColumn('shop_categories.shop_id', 'shop_category_mappings.target_shop_id');
}
}