Laravel -T
SQL语句调试
DB::enableQueryLog();
SQL语句
dd(DB::getQueryLog());
with语句拼接
$this->with(['cureMedicines' => function ($query) use ($id) {
$query->select('patient_id', 'item_id', 'name')->with(['item' => function ($query) use ($id) {
$query->where('id', $id)->select();
}]);
}]);
添加公共模型
static::addGlobalScope(new Auth(0));
移除公共模型
static::withoutGlobalScopes([Auth::class])->select();