2021-07-13 02:31:56 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a ScopeActive to an Eloquent Model to only show active services (including those soon to be active)
|
|
|
|
*/
|
|
|
|
namespace App\Traits;
|
|
|
|
|
|
|
|
use App\Models\Service;
|
|
|
|
|
|
|
|
trait ScopeServiceActive
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Only query active service records
|
|
|
|
*/
|
|
|
|
public function scopeServiceActive($query)
|
|
|
|
{
|
|
|
|
return $query->where(function($q) {
|
2022-04-19 07:07:39 +00:00
|
|
|
return $q->where('services.active',TRUE)
|
2021-07-13 02:31:56 +00:00
|
|
|
->orWhere(function($q) {
|
|
|
|
return $q->whereNotNull('order_status')
|
2022-04-19 07:07:39 +00:00
|
|
|
->whereNotIn('services.order_status',Service::INACTIVE_STATUS);
|
2021-07-13 02:31:56 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|