feat: 微客宝H5客户端 - 基础架构+核心页面
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Client;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Crm\Customer;
|
||||
use App\Models\Nanny\Nanny;
|
||||
use App\Models\Nanny\NannyOrder;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class NannyController extends Controller
|
||||
{
|
||||
/**
|
||||
* 当前派单月嫂信息
|
||||
*/
|
||||
public function myNanny(Request $request): JsonResponse
|
||||
{
|
||||
/** @var Customer $customer */
|
||||
$customer = $request->user();
|
||||
|
||||
$order = NannyOrder::withoutGlobalScope('store')
|
||||
->where('customer_id', $customer->id)
|
||||
->whereIn('status', [2, 3])
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if (!$order) {
|
||||
return $this->success(null);
|
||||
}
|
||||
|
||||
$order->load('nanny');
|
||||
|
||||
return $this->success([
|
||||
'order' => $order,
|
||||
'nanny' => $order->nanny,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 月嫂订单列表(分页)
|
||||
*/
|
||||
public function orders(Request $request): JsonResponse
|
||||
{
|
||||
/** @var Customer $customer */
|
||||
$customer = $request->user();
|
||||
|
||||
$query = NannyOrder::withoutGlobalScope('store')
|
||||
->where('customer_id', $customer->id)
|
||||
->with('nanny:id,name,level,phone');
|
||||
|
||||
return $this->paginate(
|
||||
$query->orderByDesc('id')->paginate(15)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user