Start of service display

This commit is contained in:
Deon George
2019-06-29 10:14:12 +10:00
parent a426c7b1a4
commit 6103b61265
14 changed files with 426 additions and 33 deletions

View File

@@ -4,6 +4,8 @@ namespace App\Models\Base;
use Illuminate\Database\Eloquent\Model;
use App\Models\Service;
abstract class ServiceType extends Model
{
public $timestamps = FALSE;
@@ -17,4 +19,28 @@ abstract class ServiceType extends Model
{
return $this->morphOne(Service::class,'type','model','id');
}
/** SCOPES */
/**
* Search for a record
*
* @param $query
* @param string $term
* @return
*/
public function scopeSearch($query,string $term)
{
return $query
->with(['service'])
->join('ab_service','ab_service.id','=',$this->getTable().'.service_id')
->Where('ab_service.id','like','%'.$term.'%');
}
/** ATTRIBUTES **/
public function getTypeAttribute()
{
return strtolower((new \ReflectionClass($this))->getShortName());
}
}