Start of service display
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user