diff --git a/plugs/think-plugs-inspection/src/controller/api/auth/TicketRepair.php b/plugs/think-plugs-inspection/src/controller/api/auth/TicketRepair.php new file mode 100644 index 0000000..3033812 --- /dev/null +++ b/plugs/think-plugs-inspection/src/controller/api/auth/TicketRepair.php @@ -0,0 +1,22 @@ +scope(['notFinish'])->with(['ticket'])->where(['staff_id'=>$this->staff->id]); + $keyword = $this->request->get('keyword', null); + if ($keyword) { + $query->where('title', 'like', "%{$keyword}%"); + } + $pageData = $query->paginate(); + $this->success('获取工单列表', $pageData); + } + +} \ No newline at end of file diff --git a/plugs/think-plugs-inspection/src/controller/api/auth/TicketVerify.php b/plugs/think-plugs-inspection/src/controller/api/auth/TicketVerify.php new file mode 100644 index 0000000..726ad16 --- /dev/null +++ b/plugs/think-plugs-inspection/src/controller/api/auth/TicketVerify.php @@ -0,0 +1,22 @@ +scope(['notFinish'])->with(['ticket'])->where(['staff_id'=>$this->staff->id]); + $keyword = $this->request->get('keyword', null); + if ($keyword) { + $query->where('title', 'like', "%{$keyword}%"); + } + $pageData = $query->paginate(); + $this->success('获取工单列表', $pageData); + } + +} \ No newline at end of file diff --git a/plugs/think-plugs-inspection/src/controller/api/auth/TicketView.php b/plugs/think-plugs-inspection/src/controller/api/auth/TicketView.php new file mode 100644 index 0000000..5a2fe77 --- /dev/null +++ b/plugs/think-plugs-inspection/src/controller/api/auth/TicketView.php @@ -0,0 +1,22 @@ +scope(['notFinish'])->with(['ticket'])->where(['staff_id'=>$this->staff->id]); + $keyword = $this->request->get('keyword', null); + if ($keyword) { + $query->where('title', 'like', "%{$keyword}%"); + } + $pageData = $query->paginate(); + $this->success('获取工单列表', $pageData); + } + +} \ No newline at end of file diff --git a/plugs/think-plugs-ticket/src/model/TicketRepair.php b/plugs/think-plugs-ticket/src/model/TicketRepair.php index d66060f..cb1a6f7 100644 --- a/plugs/think-plugs-ticket/src/model/TicketRepair.php +++ b/plugs/think-plugs-ticket/src/model/TicketRepair.php @@ -22,4 +22,9 @@ class TicketRepair extends Model { return str2arr($data['imgs'] ?: '', '|'); } + + public function scopeNotFinish($query) + { + $query->where('status', '=', '0'); + } } \ No newline at end of file diff --git a/plugs/think-plugs-ticket/src/model/TicketTicket.php b/plugs/think-plugs-ticket/src/model/TicketTicket.php index ce24030..bbda17b 100644 --- a/plugs/think-plugs-ticket/src/model/TicketTicket.php +++ b/plugs/think-plugs-ticket/src/model/TicketTicket.php @@ -125,6 +125,10 @@ class TicketTicket extends Model return $this->hasMany(TicketRepair::class, 'ticket_id')->order('create_at', 'desc'); } + public function views() { + return $this->hasMany(TicketView::class, 'ticket_id')->order('create_at', 'desc'); + } + public function repair_accept() { return $this->hasMany(TicketRepairAccept::class, 'ticket_id')->order('create_at', 'desc'); diff --git a/plugs/think-plugs-ticket/src/model/TicketVerify.php b/plugs/think-plugs-ticket/src/model/TicketVerify.php index 4a7213e..1ac8ac4 100644 --- a/plugs/think-plugs-ticket/src/model/TicketVerify.php +++ b/plugs/think-plugs-ticket/src/model/TicketVerify.php @@ -22,4 +22,9 @@ class TicketVerify extends Model { return str2arr($data['imgs'] ?: '', '|'); } + + public function scopeNotFinish($query) + { + $query->where('status', '=', '0'); + } } \ No newline at end of file diff --git a/plugs/think-plugs-ticket/src/model/TicketView.php b/plugs/think-plugs-ticket/src/model/TicketView.php new file mode 100644 index 0000000..1a3ecd6 --- /dev/null +++ b/plugs/think-plugs-ticket/src/model/TicketView.php @@ -0,0 +1,30 @@ +belongsTo(TicketTicket::class, 'ticket_id'); + } + + public function staff() + { + return $this->belongsTo(InspectionStaff::class, 'staff_id'); + } + + public function getImgsArrAttr($value, $data) + { + return str2arr($data['imgs'] ?: '', '|'); + } + + public function scopeNotFinish($query) + { + $query->where('status', '=', '0'); + } +} \ No newline at end of file