sarga/packages/Webkul/Attribute/src/Models/AttributeOption.php

45 lines
1.1 KiB
PHP
Raw Normal View History

2018-07-11 05:41:27 +00:00
<?php
namespace Webkul\Attribute\Models;
2019-02-26 06:25:00 +00:00
use Illuminate\Support\Facades\Storage;
2018-07-24 11:11:32 +00:00
use Webkul\Core\Eloquent\TranslatableModel;
2019-02-18 07:30:40 +00:00
use Webkul\Attribute\Contracts\AttributeOption as AttributeOptionContract;
2018-07-11 05:41:27 +00:00
2019-02-18 07:30:40 +00:00
class AttributeOption extends TranslatableModel implements AttributeOptionContract
2018-07-11 05:41:27 +00:00
{
2018-07-17 13:28:34 +00:00
public $timestamps = false;
2018-07-11 05:41:27 +00:00
public $translatedAttributes = ['label'];
2018-07-17 13:28:34 +00:00
2019-02-26 06:25:00 +00:00
protected $fillable = ['admin_name', 'swatch_value', 'sort_order', 'attribute_id'];
2018-07-17 13:28:34 +00:00
2019-04-05 06:12:52 +00:00
protected $with = ['translations'];
2018-07-17 13:28:34 +00:00
/**
* Get the attribute that owns the attribute option.
*/
public function attribute()
{
2019-02-26 06:25:00 +00:00
return $this->belongsTo(AttributeProxy::modelClass());
}
/**
* Get image url for the swatch value url.
*/
public function swatch_value_url()
{
if ($this->swatch_value && $this->attribute->swatch_type == 'image')
return Storage::url($this->swatch_value);
return;
}
/**
* Get image url for the product image.
*/
public function getSwatchValueUrlAttribute()
{
return $this->swatch_value_url();
2018-07-17 13:28:34 +00:00
}
2018-07-11 05:41:27 +00:00
}