123456789101112131415161718192021222324252627282930 |
- <?php
- namespace Packages\Product\Models;
- use Illuminate\Database\Eloquent\SoftDeletes;
- use Illuminate\Database\Eloquent\Model;
- class Attribute extends Model
- {
- use SoftDeletes;
- protected $table = 'attributes';
- protected $fillable=['title', 'key', 'use_in_veriation'];
- public function products()
- {
- return $this->morphedByMany(Product::class, 'attributable')->withPivot(['val_attribute']);
- }
- public function getUseInVeriationAttribute($value)
- {
- switch ($value) {
- case 0:
- $UseInVeriation = 'خیر';
- break;
- case 1:
- $UseInVeriation = 'بله';
- break;
- default:
- $UseInVeriation = '';
- }
- return $UseInVeriation ;
- }
- }
|