Commit ff2c8438 by 杨树贤

寻报价数量

parent a63f1e23
...@@ -64,7 +64,9 @@ class AuthApiController extends Controller ...@@ -64,7 +64,9 @@ class AuthApiController extends Controller
$cookie = Cookie::make('sem_email', Auth::user()->email, config('session.lifetime'), null, null, false, $cookie = Cookie::make('sem_email', Auth::user()->email, config('session.lifetime'), null, null, false,
false); false);
Cookie::queue($cookie); Cookie::queue($cookie);
$userIdCookie = Cookie::make('sem_user_id', Auth::user()->id, config('session.lifetime'), null, null, false,
false);
Cookie::queue($userIdCookie);
return $this->setSuccess('Login success'); return $this->setSuccess('Login success');
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Http\Services\InquiryService;
use Illuminate\Http\Request; use Illuminate\Http\Request;
class UserController extends Controller class UserController extends Controller
...@@ -23,7 +24,10 @@ class UserController extends Controller ...@@ -23,7 +24,10 @@ class UserController extends Controller
public function inquiry(Request $request) public function inquiry(Request $request)
{ {
return view('user.inquiry'); $userId = $_COOKIE['sem_user_id'];
//获取不同状态的统计
$statusCount = InquiryService::getStatusCount($userId);
return view('user.inquiry',compact('statusCount'));
} }
public function account(Request $request) public function account(Request $request)
{ {
......
...@@ -14,5 +14,6 @@ class EncryptCookies extends Middleware ...@@ -14,5 +14,6 @@ class EncryptCookies extends Middleware
protected $except = [ protected $except = [
// //
'sem_email', 'sem_email',
'sem_user_id',
]; ];
} }
...@@ -92,4 +92,12 @@ class InquiryService ...@@ -92,4 +92,12 @@ class InquiryService
return 'XJ' . date('Ymd',$time) . $id; return 'XJ' . date('Ymd',$time) . $id;
} }
public static function getStatusCount($userId)
{
$pending = InquiryModel::getInquiryCountByStatus($userId,InquiryModel::STATUS_PENDING);
$processed = InquiryModel::getInquiryCountByStatus($userId,InquiryModel::STATUS_PROCESSED);
$closed = InquiryModel::getInquiryCountByStatus($userId,InquiryModel::STATUS_CLOSED);
return compact('pending', 'processed', 'closed');
}
} }
...@@ -13,6 +13,10 @@ class InquiryModel extends Model ...@@ -13,6 +13,10 @@ class InquiryModel extends Model
const PRIORITY_HIGH = 2; const PRIORITY_HIGH = 2;
const STATUS_PROCESSED = 1;
const STATUS_PENDING = 0;
const STATUS_CLOSED = -1;
public function inquiry_items() public function inquiry_items()
{ {
return $this->hasMany(InquiryItemsModel::class, 'inquiry_id', 'inquiry_id'); return $this->hasMany(InquiryItemsModel::class, 'inquiry_id', 'inquiry_id');
...@@ -23,4 +27,9 @@ class InquiryModel extends Model ...@@ -23,4 +27,9 @@ class InquiryModel extends Model
return self::insertGetId($inquiry); return self::insertGetId($inquiry);
} }
public static function getInquiryCountByStatus($userId, $status)
{
return self::where('user_id', $userId)->where('status', $status)->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