57 lines
1.2 KiB
PHP
57 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Traits\HasPlans;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use OwenIt\Auditing\Contracts\Auditable;
|
|
|
|
class ConfigOption extends Model implements Auditable
|
|
{
|
|
use \App\Models\Traits\Auditable, HasFactory, HasPlans;
|
|
|
|
protected $dontShowUnavailablePrice = true;
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'env_variable',
|
|
'type',
|
|
'sort',
|
|
'hidden',
|
|
'parent_id',
|
|
'upgradable',
|
|
];
|
|
|
|
/**
|
|
* Get the parent option.
|
|
*/
|
|
public function parent()
|
|
{
|
|
return $this->belongsTo(ConfigOption::class, 'parent_id');
|
|
}
|
|
|
|
/**
|
|
* Get the options that belong to the parent. (children or options)
|
|
*/
|
|
public function children()
|
|
{
|
|
return $this->hasMany(ConfigOption::class, 'parent_id')->orderBy('sort');
|
|
}
|
|
|
|
/**
|
|
* Get the products that belong to the option.
|
|
*/
|
|
public function products()
|
|
{
|
|
return $this->belongsToMany(Product::class, 'config_option_products');
|
|
}
|
|
|
|
/**
|
|
* Get the service configs that belong to the option.
|
|
*/
|
|
public function serviceConfigs()
|
|
{
|
|
return $this->hasMany(ServiceConfig::class, 'config_option_id');
|
|
}
|
|
}
|