Commit 388a016f by 杨树贤

询价数量返回修改

parent ff2c8438
...@@ -27,6 +27,7 @@ class UserController extends Controller ...@@ -27,6 +27,7 @@ class UserController extends Controller
$userId = $_COOKIE['sem_user_id']; $userId = $_COOKIE['sem_user_id'];
//获取不同状态的统计 //获取不同状态的统计
$statusCount = InquiryService::getStatusCount($userId); $statusCount = InquiryService::getStatusCount($userId);
dd($statusCount);
return view('user.inquiry',compact('statusCount')); return view('user.inquiry',compact('statusCount'));
} }
public function account(Request $request) public function account(Request $request)
......
...@@ -96,8 +96,8 @@ class InquiryService ...@@ -96,8 +96,8 @@ class InquiryService
{ {
$pending = InquiryModel::getInquiryCountByStatus($userId,InquiryModel::STATUS_PENDING); $pending = InquiryModel::getInquiryCountByStatus($userId,InquiryModel::STATUS_PENDING);
$processed = InquiryModel::getInquiryCountByStatus($userId,InquiryModel::STATUS_PROCESSED); $processed = InquiryModel::getInquiryCountByStatus($userId,InquiryModel::STATUS_PROCESSED);
$closed = InquiryModel::getInquiryCountByStatus($userId,InquiryModel::STATUS_CLOSED); $all = InquiryModel::getInquiryCountByStatus($userId);
return compact('pending', 'processed', 'closed'); return compact('pending', 'processed', 'all');
} }
} }
...@@ -27,9 +27,13 @@ class InquiryModel extends Model ...@@ -27,9 +27,13 @@ class InquiryModel extends Model
return self::insertGetId($inquiry); return self::insertGetId($inquiry);
} }
public static function getInquiryCountByStatus($userId, $status) public static function getInquiryCountByStatus($userId, $status = null)
{ {
return self::where('user_id', $userId)->where('status', $status)->count(); $query = self::where('user_id', $userId);
if ($status !== null) {
$query->where('status', $status);
}
return $query->count();
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment