Start work on updating services

This commit is contained in:
Deon George
2022-04-19 17:07:39 +10:00
parent ebf08ea414
commit 621a132e35
63 changed files with 1038 additions and 612 deletions

View File

@@ -15,10 +15,10 @@ trait ScopeServiceActive
public function scopeServiceActive($query)
{
return $query->where(function($q) {
return $q->where('ab_service.active',TRUE)
return $q->where('services.active',TRUE)
->orWhere(function($q) {
return $q->whereNotNull('order_status')
->whereNotIn('ab_service.order_status',Service::INACTIVE_STATUS);
->whereNotIn('services.order_status',Service::INACTIVE_STATUS);
});
});
}

View File

@@ -16,6 +16,6 @@ trait ScopeServiceUserAuthorised
public function scopeServiceUserAuthorised($query,User $uo)
{
return $query
->whereIN('ab_service.account_id',$uo->all_accounts()->pluck('id')->unique()->toArray());
->whereIN('services.account_id',$uo->all_accounts()->pluck('id')->unique()->toArray());
}
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* Service Types that have a domain name attribute.
*/
namespace App\Traits;
use App\Models\TLD;
trait ServiceDomains
{
/* INTERFACES */
/**
* There is no detailed description for domain services
*
* @return string
*/
public function getServiceDescriptionAttribute(): string
{
return '';
}
/**
* The name of the domain with its TLD
*
* @return string
*/
public function getServiceNameAttribute(): string
{
return strtoupper(sprintf('%s.%s',$this->domain_name,$this->tld->name));
}
/* RELATIONS */
public function tld()
{
return $this->belongsTo(TLD::class);
}
/* SCOPES */
/**
* Search for a record
*
* @param $query
* @param string $term
* @return mixed
*/
public function scopeSearch($query,string $term)
{
// If we have a period in the name, we'll ignore everything after it.
$term = strstr($term,'.',TRUE) ?: $term;
// Build our where clause
return parent::scopeSearch($query,$term)
->orwhere('domain_name','like','%'.$term.'%');
}
}