第一種方法
<?php
namespace Table;
use Illuminate\Database\Eloquent\Builder;
/**
*
*
*/
class TSingleService extends Table{
protected $table = 'single_service_list';
public $timestamps = false;
/**
* 設置單項服務全局查詢條件
*/
protected static function boot()
{
parent::boot(); // TODO: Change the autogenerated stub
static::addGlobalScope('avaiable',function (Builder $builder){
$builder->where('deleted_at','=',NULL);
});
}
}
第二種方法
<?php
namespace Table;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
*
*
*/
class TSingleService extends Table{
use SoftDeletes;
protected $table = 'single_service_list';
protected $dates = ['deleted_at'];
public $timestamps = false;
}