2018-07-27 06:22:12 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Webkul\Product\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2018-07-31 07:50:54 +00:00
|
|
|
use Webkul\Attribute\Models\Attribute;
|
2018-07-27 09:30:48 +00:00
|
|
|
use Webkul\Category\Models\Category;
|
2018-07-31 07:50:54 +00:00
|
|
|
use Webkul\Inventory\Models\InventorySource;
|
2018-08-01 06:11:33 +00:00
|
|
|
use Webkul\Attribute\Models\AttributeFamily;
|
2018-07-27 06:22:12 +00:00
|
|
|
|
|
|
|
|
class Product extends Model
|
|
|
|
|
{
|
2018-07-31 07:50:54 +00:00
|
|
|
protected $fillable = ['type', 'attribute_family_id', 'sku'];
|
2018-07-27 09:30:48 +00:00
|
|
|
|
2018-08-01 06:11:33 +00:00
|
|
|
protected $with = ['super_attributes'];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the product attribute family that owns the product.
|
|
|
|
|
*/
|
|
|
|
|
public function attribute_family()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(AttributeFamily::class);
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-27 09:30:48 +00:00
|
|
|
/**
|
|
|
|
|
* The categories that belong to the product.
|
|
|
|
|
*/
|
|
|
|
|
public function categories()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsToMany(Category::class, 'product_categories');
|
|
|
|
|
}
|
2018-07-31 07:50:54 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The inventories that belong to the product.
|
|
|
|
|
*/
|
|
|
|
|
public function inventories()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsToMany(InventorySource::class, 'product_inventories');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The super attributes that belong to the product.
|
|
|
|
|
*/
|
|
|
|
|
public function super_attributes()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsToMany(Attribute::class, 'product_super_attributes');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The related products that belong to the product.
|
|
|
|
|
*/
|
|
|
|
|
public function related_products()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsToMany(self::class, 'product_relations');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The up sells that belong to the product.
|
|
|
|
|
*/
|
|
|
|
|
public function up_sells()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsToMany(self::class, 'product_up_sells');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The cross sells that belong to the product.
|
|
|
|
|
*/
|
|
|
|
|
public function cross_sells()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsToMany(self::class, 'product_cross_sells');
|
|
|
|
|
}
|
2018-08-01 06:11:33 +00:00
|
|
|
|
|
|
|
|
public function __get($name) {
|
|
|
|
|
// if(array_key_exists($name, $this->data)) {
|
|
|
|
|
// return $this->data[$name];
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2018-07-27 06:22:12 +00:00
|
|
|
}
|