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\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
|
|
|
{
|
2021-06-30 06:20:55 +00:00
|
|
|
/**
|
|
|
|
|
* Indicates if the model should be timestamped.
|
|
|
|
|
*
|
|
|
|
|
* @var bool
|
|
|
|
|
*/
|
2018-08-02 04:19:45 +00:00
|
|
|
public $timestamps = false;
|
|
|
|
|
|
2018-08-09 04:35:13 +00:00
|
|
|
/**
|
2021-06-30 06:20:55 +00:00
|
|
|
* Attribute type fields.
|
|
|
|
|
*
|
2018-08-09 04:35:13 +00:00
|
|
|
* @var array
|
|
|
|
|
*/
|
|
|
|
|
public static $attributeTypeFields = [
|
2020-02-20 06:12:17 +00:00
|
|
|
'text' => 'text_value',
|
|
|
|
|
'textarea' => 'text_value',
|
|
|
|
|
'price' => 'float_value',
|
|
|
|
|
'boolean' => 'boolean_value',
|
|
|
|
|
'select' => 'integer_value',
|
2018-08-09 04:35:13 +00:00
|
|
|
'multiselect' => 'text_value',
|
2020-02-20 06:12:17 +00:00
|
|
|
'datetime' => 'datetime_value',
|
|
|
|
|
'date' => 'date_value',
|
|
|
|
|
'file' => 'text_value',
|
|
|
|
|
'image' => 'text_value',
|
|
|
|
|
'checkbox' => 'text_value',
|
2018-08-09 04:35:13 +00:00
|
|
|
];
|
|
|
|
|
|
2021-06-30 06:20:55 +00:00
|
|
|
/**
|
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
|
*
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
2018-08-02 04:19:45 +00:00
|
|
|
protected $fillable = [
|
2019-01-22 12:55:47 +00:00
|
|
|
'product_id',
|
|
|
|
|
'attribute_id',
|
|
|
|
|
'locale',
|
|
|
|
|
'channel',
|
|
|
|
|
'text_value',
|
|
|
|
|
'boolean_value',
|
|
|
|
|
'integer_value',
|
|
|
|
|
'float_value',
|
|
|
|
|
'datetime_value',
|
|
|
|
|
'date_value',
|
2020-03-04 06:32:53 +00:00
|
|
|
'json_value',
|
2019-01-22 12:55:47 +00:00
|
|
|
];
|
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
|
|
|
}
|
2021-06-30 06:20:55 +00:00
|
|
|
}
|