2018-07-31 07:50:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Webkul\Product\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2019-02-18 07:30:40 +00:00
|
|
|
use Webkul\Attribute\Models\AttributeProxy;
|
|
|
|
|
use Webkul\Channel\Models\ChannelProxy;
|
|
|
|
|
use Webkul\Product\Contracts\ProductAttributeValue as ProductAttributeValueContract;
|
2018-07-31 07:50:54 +00:00
|
|
|
|
2019-02-18 07:30:40 +00:00
|
|
|
class ProductAttributeValue extends Model implements ProductAttributeValueContract
|
2018-07-31 07:50:54 +00:00
|
|
|
{
|
2018-08-02 04:19:45 +00:00
|
|
|
public $timestamps = false;
|
|
|
|
|
|
|
|
|
|
protected $with = ['attribute'];
|
|
|
|
|
|
2018-08-09 04:35:13 +00:00
|
|
|
/**
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
|
|
|
|
public static $attributeTypeFields = [
|
|
|
|
|
'text' => 'text_value',
|
|
|
|
|
'textarea' => 'text_value',
|
|
|
|
|
'price' => 'float_value',
|
|
|
|
|
'boolean' => 'boolean_value',
|
|
|
|
|
'select' => 'integer_value',
|
|
|
|
|
'multiselect' => 'text_value',
|
2018-09-20 10:01:51 +00:00
|
|
|
'datetime' => 'datetime_value',
|
2018-08-09 04:35:13 +00:00
|
|
|
'date' => 'date_value',
|
|
|
|
|
];
|
|
|
|
|
|
2018-08-02 04:19:45 +00:00
|
|
|
protected $fillable = [
|
2019-01-22 12:55:47 +00:00
|
|
|
'product_id',
|
|
|
|
|
'attribute_id',
|
|
|
|
|
'channel_id',
|
|
|
|
|
'locale',
|
|
|
|
|
'channel',
|
|
|
|
|
'text_value',
|
|
|
|
|
'boolean_value',
|
|
|
|
|
'integer_value',
|
|
|
|
|
'float_value',
|
|
|
|
|
'datetime_value',
|
|
|
|
|
'date_value',
|
|
|
|
|
'json_value'
|
|
|
|
|
];
|
2018-08-02 04:19:45 +00:00
|
|
|
|
2018-07-31 07:50:54 +00:00
|
|
|
/**
|
2018-08-02 04:19:45 +00:00
|
|
|
* Get the attribute that owns the attribute value.
|
2018-07-31 07:50:54 +00:00
|
|
|
*/
|
2018-08-02 04:19:45 +00:00
|
|
|
public function attribute()
|
2018-07-31 07:50:54 +00:00
|
|
|
{
|
2019-02-18 07:30:40 +00:00
|
|
|
return $this->belongsTo(AttributeProxy::modelClass());
|
2018-07-31 07:50:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the product that owns the attribute value.
|
|
|
|
|
*/
|
|
|
|
|
public function product()
|
|
|
|
|
{
|
2019-02-18 07:30:40 +00:00
|
|
|
return $this->belongsTo(ProductProxy::modelClass());
|
2018-07-31 07:50:54 +00:00
|
|
|
}
|
2018-08-02 04:19:45 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the channel that owns the attribute value.
|
|
|
|
|
*/
|
|
|
|
|
public function channel()
|
|
|
|
|
{
|
2019-02-18 07:30:40 +00:00
|
|
|
return $this->belongsTo(ChannelProxy::modelClass());
|
2018-08-02 04:19:45 +00:00
|
|
|
}
|
2018-07-31 07:50:54 +00:00
|
|
|
}
|