|
|
@@ -117,13 +117,35 @@ class WorkOrder extends Model
|
|
|
return $this->belongsTo(OrderIssueType::class,'order_issue_type_id');
|
|
|
}
|
|
|
|
|
|
+ /** 对应问题件 */
|
|
|
+ public function orderIssue(): BelongsTo
|
|
|
+ {
|
|
|
+ return $this->belongsTo(OrderIssue::class,'order_id','order_id');
|
|
|
+ }
|
|
|
+
|
|
|
public function scopeFilter($query, $filters)
|
|
|
{
|
|
|
return $filters->apply($query);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /** 默认 with 参数 */
|
|
|
public function scopeDefaultWith($query)
|
|
|
{
|
|
|
+ $query->with(['type','issueType','creator','reviewer','order'=>function($query){
|
|
|
+ /** @var $query Builder */
|
|
|
+ $query->with('packages','logistic');
|
|
|
+ },'orderIssue'=>function($query){
|
|
|
+ /** @var $query Builder */
|
|
|
+ $query->with(['issueType','logs'=>function($query){
|
|
|
+ if (Gate::denies('订单管理-问题件-客户不可见')){
|
|
|
+ $query->with('user')->orderByDesc('created_at');
|
|
|
+ } else{
|
|
|
+ $query->with('user')->where('tag','=',0)->orderByDesc('created_at');
|
|
|
+ }
|
|
|
+ }]);
|
|
|
+ }]);
|
|
|
+
|
|
|
$query->with(['type', 'creator', 'order' => function ($query) {
|
|
|
/** @var $query Builder */
|
|
|
$query->with(['packages', 'issue'=>function($query){
|