Add Corporate Specialities
This commit is contained in:
@@ -31,4 +31,19 @@ class CorporateService extends Model
|
||||
{
|
||||
return $this->hasOne(Service::class, 'code', 'service_code');
|
||||
}
|
||||
|
||||
public function specialities()
|
||||
{
|
||||
return $this->hasMany(CorporateServiceSpeciality::class, 'corporate_service_id');
|
||||
}
|
||||
|
||||
public function scopeFilter($query, array $filters)
|
||||
{
|
||||
if (!empty($filters['search'])) {
|
||||
$query->where('service_code', 'LIKE', '%'.$filters['search'].'%')
|
||||
->orWhereHas('service', function($service) use ($filters) {
|
||||
$service->where('name', 'LIKE', '%'.$filters['search'].'%');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
34
app/Models/CorporateServiceSpeciality.php
Normal file
34
app/Models/CorporateServiceSpeciality.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 CorporateServiceSpeciality extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes, Blameable;
|
||||
|
||||
protected $fillable = [
|
||||
'corporate_service_id',
|
||||
'speciality_id',
|
||||
'status'
|
||||
];
|
||||
|
||||
public function corporateService()
|
||||
{
|
||||
return $this->belongsTo(CorporateService::class, 'corporate_service_id');
|
||||
}
|
||||
|
||||
public function corporate()
|
||||
{
|
||||
return $this->hasOneThrough(Corporate::class, CorporateService::class);
|
||||
}
|
||||
|
||||
public function speciality()
|
||||
{
|
||||
return $this->belongsTo(Speciality::class, 'speciality_id');
|
||||
}
|
||||
}
|
||||
23
app/Models/Speciality.php
Normal file
23
app/Models/Speciality.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?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 Speciality extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes, Blameable;
|
||||
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'name'
|
||||
];
|
||||
|
||||
protected $guarded = [
|
||||
'code',
|
||||
'name'
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user