Add all files
This commit is contained in:
56
app/Models/ConfigOption.php
Normal file
56
app/Models/ConfigOption.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Traits\HasPlans;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ConfigOption extends Model
|
||||
{
|
||||
use 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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user