fix reset password email

This commit is contained in:
Omair Saleh
2018-12-20 17:54:01 +08:00
parent a51f4db8e8
commit 85e2d1f244
6 changed files with 431 additions and 107 deletions
+8 -2
View File
@@ -8,7 +8,6 @@ class Booking extends Model
{
// protected $guarded = [];
protected $hidden = array( "user",
"user_id",
"rate_id",
"rmb_book_amount",
"rmb_book_pay_method",
@@ -24,10 +23,17 @@ class Booking extends Model
"usd_book_cnap",
"usd_book_bank_branch");
protected $fillable = ['term', 'rate_id', 'user_id', 'amount', 'account_name', 'account_num', 'bank_name',
protected $fillable = ['id', 'term', 'rate_id', 'user_id', 'amount', 'account_name', 'account_num', 'bank_name',
'bank_branch', 'company_name'];
public $timestamps = true;
public function scopeUserBooking($query, $userId){
if($userId){
return $query->where('user_id', $userId);
}
return $query;
}
public function user(){
return $this->belongsTo(User::class);
+111 -101
View File
@@ -106,22 +106,27 @@ class BookingController extends Controller
public function userComplete(){
$user = Auth::user();
$bookings = Booking::select('user_id', 'id', 'created_at', 'status', 'rate', 'term', 'amount', 'bia', 'verification_status')
->where('user_id', Auth::user()->id)
->where('status', '=', '5')
->where(function ($query) {
$query->where('term', '=', 'x2_cash')
->orwhere('term', '=', 'x2_cheque')
->orwhere('term', '=', 'x2_ba');
})
->orwhere('status', '=', '7')
->where(function ($query) {
$query->where('term', '=', 'x1_cash')
->orwhere('term', '=', 'x1_cheque')
->orwhere('term', '=', 'x1_ba');
})
->orderby('updated_at','desc')
->paginate(10);
$bookings = Booking::where('user_id', $user->id)
->where(function ($query) {
$query->where(function ($query) {
$query->where('status', '5')
->where(function ($query) {
$query->where('term', 'x2_cash')
->orwhere('term', 'x2_cheque')
->orwhere('term', 'x2_ba');
});
})
->orwhere(function ($query) {
$query->where('status', '7')
->where(function ($query) {
$query->where('term', 'x1_cash')
->orwhere('term', 'x1_cheque')
->orwhere('term', 'x1_ba');
});
});
})
->orderby('updated_at','desc')
->paginate(10);
// reformat to fit frontend structure
foreach ($bookings as $booking) {
@@ -182,99 +187,104 @@ class BookingController extends Controller
return $bookings;
}
public function adminIndex(){
$user = Auth::user();
$bookings = Booking::select('user_id', 'id', 'created_at', 'admin_status', 'rate', 'term', 'amount', 'bia', 'verification_status')
public function adminIndex(?string $userId = null){
$user = Auth::user();
$bookings = Booking::UserBooking($userId)->select('user_id', 'id', 'created_at', 'admin_status', 'rate', 'term', 'amount', 'bia', 'verification_status')
->where('admin_status', '<', '6')
->orwhere(function ($query) {
$query->where('admin_status', '=', '6')
->where('term', '!=', 'x2_cheque')
->where('term', '!=', 'x2_ba')
->where('term', '!=', 'x2_cash');
})
->orderby('updated_at','desc')
->paginate(30);
// reformat to fit frontend structure
foreach ($bookings as $booking) {
// set timeout
$date1 = new DateTime($booking->created_at);
$date2 = new DateTime();
$time_in_seconds = SettingCredit::orderby('updated_at','desc')->first()->time_limit;
$difference_in_seconds = ($date1->format('U') + $time_in_seconds) - ($date2->format('U'));
$booking->timeout = $difference_in_seconds;
// TODO : you can make it better
if($difference_in_seconds < 0 ){
$booking->timeout = 0;
}
// TODO : transfer_amount change name to bia
$booking->transfer_amount = $booking->bia;
$term = $booking->term;
if ($booking->term == "x2_cash" || $booking->term == "x2_cheque" || $booking->term == "x2_ba"){
$booking->track_status = "(". $booking->admin_status ."/6)";
}
else{
$booking->track_status = "(". $booking->admin_status ."/7)";
}
switch ($booking->admin_status) {
case 1:
$status_desc = "Waiting customer upload bank slip";
break;
case 2:
$status_desc = "Verify user bank slip";
break;
case 3:
$status_desc = "Generate supplier booking report";
break;
case 4:
$status_desc = "Supplier booking report. Please confirm with your booking.";
break;
case 5:
$status_desc = "Please, upload China Bankslip";
break;
case 6:
$status_desc = "Waiting customer to upload purchase order";
if ($booking->term == "x2_cash" || $booking->term == "x2_cheque" || $booking->term == "x2_ba"){
$status_desc = "Order Completed";
}
break;
case 7:
$status_desc = "Customer has uploaded purchase order, please upload invoice";
break;
case 8:
$status_desc = "Booking Completed";
break;
default:
$status_desc = "";
}
$booking->marking = $booking->user->marking;
$booking->status_desc = $status_desc;
}
return $bookings;
}
public function adminBookComplete(){
$user = Auth::user();
$bookings = Booking::select('user_id', 'id', 'created_at', 'admin_status', 'rate', 'term', 'amount', 'bia', 'verification_status')
->where('admin_status', '=', '6')
->where(function ($query) {
$query->where('term', '=', 'x2_cash')
->orwhere('term', '=', 'x2_cheque')
->orwhere('term', '=', 'x2_ba');
})
->orwhere('admin_status', '=', '7')
->where(function ($query) {
$query->where('term', '=', 'x1_cash')
->orwhere('term', '=', 'x1_cheque')
->orwhere('term', '=', 'x1_ba');
})
->orderby('updated_at','desc')
->paginate(10);
->paginate(30);
// reformat to fit frontend structure
foreach ($bookings as $booking) {
// set timeout
$date1 = new DateTime($booking->created_at);
$date2 = new DateTime();
$time_in_seconds = SettingCredit::orderby('updated_at','desc')->first()->time_limit;
$difference_in_seconds = ($date1->format('U') + $time_in_seconds) - ($date2->format('U'));
$booking->timeout = $difference_in_seconds;
// TODO : you can make it better
if($difference_in_seconds < 0 ){
$booking->timeout = 0;
}
// TODO : transfer_amount change name to bia
$booking->transfer_amount = $booking->bia;
$term = $booking->term;
if ($booking->term == "x2_cash" || $booking->term == "x2_cheque" || $booking->term == "x2_ba"){
$booking->track_status = "(". $booking->admin_status ."/6)";
}
else{
$booking->track_status = "(". $booking->admin_status ."/7)";
}
switch ($booking->admin_status) {
case 1:
$status_desc = "Waiting customer upload bank slip";
break;
case 2:
$status_desc = "Verify user bank slip";
break;
case 3:
$status_desc = "Generate supplier booking report";
break;
case 4:
$status_desc = "Supplier booking report. Please confirm with your booking.";
break;
case 5:
$status_desc = "Please, upload China Bankslip";
break;
case 6:
$status_desc = "Waiting customer to upload purchase order";
if ($booking->term == "x2_cash" || $booking->term == "x2_cheque" || $booking->term == "x2_ba"){
$status_desc = "Order Completed";
}
break;
case 7:
$status_desc = "Customer has uploaded purchase order, please upload invoice";
break;
case 8:
$status_desc = "Booking Completed";
break;
default:
$status_desc = "";
}
$booking->marking = $booking->user->marking;
$booking->status_desc = $status_desc;
}
return $bookings;
}
public function adminBookComplete(?string $userId = null){
$user = Auth::user();
$bookings = Booking::UserBooking($userId)->select('user_id', 'id', 'created_at', 'admin_status', 'rate', 'term', 'amount', 'bia', 'verification_status')
->where(function ($query) {
$query->where(function ($query) {
$query->where('admin_status', '6')
->where(function ($query) {
$query->where('term', 'x2_cash')
->orwhere('term', 'x2_cheque')
->orwhere('term', 'x2_ba');
});
})
->orwhere(function ($query) {
$query->where('admin_status', '7')
->where(function ($query) {
$query->where('term', 'x1_cash')
->orwhere('term', 'x1_cheque')
->orwhere('term', 'x1_ba');
});
});
})
->orderby('updated_at','desc')
->paginate(10);
// reformat to fit frontend structure
foreach ($bookings as $booking) {
// set timeout