sarga/packages/Webkul/Product/src/Models/ProductAttributeValue.php

69 lines
1.6 KiB
PHP
Raw Normal View History

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
{
public $timestamps = false;
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',
2019-05-27 11:21:27 +00:00
'file' => 'text_value',
'image' => 'text_value',
2019-07-15 12:30:56 +00:00
'checkbox' => 'text_value',
2018-08-09 04:35:13 +00:00
];
protected $fillable = [
'product_id',
'attribute_id',
'channel_id',
'locale',
'channel',
'text_value',
'boolean_value',
'integer_value',
'float_value',
'datetime_value',
'date_value',
'json_value'
];
2018-07-31 07:50:54 +00:00
/**
* Get the attribute that owns the attribute value.
2018-07-31 07:50:54 +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
}
/**
* 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-07-31 07:50:54 +00:00
}