Add Service Config
This commit is contained in:
@@ -67,4 +67,14 @@ class Corporate extends Model
|
||||
{
|
||||
return $this->morphMany(ImportLog::class, 'importable');
|
||||
}
|
||||
|
||||
public function services()
|
||||
{
|
||||
return $this->hasManyThrough(CorporateService::class, Service::class, 'corporate_id', 'service_code', 'id', 'service_code');
|
||||
}
|
||||
|
||||
public function corporateServices()
|
||||
{
|
||||
return $this->hasMany(CorporateService::class, 'corporate_id');
|
||||
}
|
||||
}
|
||||
|
||||
34
app/Models/CorporateService.php
Normal file
34
app/Models/CorporateService.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Blameable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class CorporateService extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes, Blameable;
|
||||
|
||||
protected $fillable = [
|
||||
'corporate_id',
|
||||
'service_code',
|
||||
'status',
|
||||
];
|
||||
|
||||
public function corporate()
|
||||
{
|
||||
return $this->belongsTo(Corporate::class);
|
||||
}
|
||||
|
||||
public function configs()
|
||||
{
|
||||
return $this->hasMany(CorporateServiceConfig::class, 'corporate_service_id');
|
||||
}
|
||||
|
||||
public function service()
|
||||
{
|
||||
return $this->hasOne(Service::class, 'code', 'service_code');
|
||||
}
|
||||
}
|
||||
24
app/Models/CorporateServiceConfig.php
Normal file
24
app/Models/CorporateServiceConfig.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Blameable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class CorporateServiceConfig extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes, Blameable;
|
||||
|
||||
protected $fillable = [
|
||||
'corporate_service_id',
|
||||
'name',
|
||||
'value'
|
||||
];
|
||||
|
||||
public function corporateService()
|
||||
{
|
||||
return $this->belongsTo(CorporateService::class, 'corporate_service_id');
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,13 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Services extends Model
|
||||
class Service extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'name',
|
||||
'description',
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user