mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-25 15:24:21 +00:00
added relationship for invoice and booking
added confirm invoice feature (after user upload the image)
This commit is contained in:
@@ -47,5 +47,11 @@ class Booking extends Model
|
||||
public function purchaseOrder(){
|
||||
return $this->hasOne(PurchaseOrder::class);
|
||||
}
|
||||
|
||||
public function invoice(){
|
||||
return $this->hasOne(Invoice::class);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -423,19 +423,6 @@ class BookingController extends Controller
|
||||
return response()->json(['message'=>'Success'],200);
|
||||
}
|
||||
|
||||
public function confirmPurchaseOrder($id){
|
||||
$booking = Booking::where('user_id',Auth::user()->id)->where('id',$id)->first();
|
||||
|
||||
$purchase_order = $booking->purchaseOrder()->first();
|
||||
|
||||
if(!$purchase_order){
|
||||
return response()->json(["message"=> "Please upload your purchase order"],400);
|
||||
}
|
||||
|
||||
$booking->status = 6;
|
||||
$booking->save();
|
||||
return response()->json(['message'=>'Success'],200);
|
||||
}
|
||||
|
||||
public function showPurchaseOrder($id){
|
||||
$booking = Booking::where('id',$id)->first();
|
||||
@@ -657,8 +644,38 @@ class BookingController extends Controller
|
||||
if($booking->save()){
|
||||
return response()->json(['message'=>"Success"],200);
|
||||
}
|
||||
}
|
||||
|
||||
public function confirmPurchaseOrder($id){
|
||||
$booking = Booking::where('user_id',Auth::user()->id)->where('id',$id)->first();
|
||||
|
||||
$purchase_order = $booking->purchaseOrder()->first();
|
||||
|
||||
if(!$purchase_order){
|
||||
return response()->json(["message"=> "Please upload your purchase order"],400);
|
||||
}
|
||||
|
||||
$booking->status = 6;
|
||||
$booking->save();
|
||||
return response()->json(['message'=>'Success'],200);
|
||||
}
|
||||
|
||||
public function confirmInvoice(Request $request, $id)
|
||||
{
|
||||
$booking = Booking::where('id', $id)->firstOrFail();
|
||||
|
||||
$invoice = $booking->invoice()->first;
|
||||
|
||||
if(!$invoice){
|
||||
return response()->json(["message"=> "Please upload your invoice"],400);
|
||||
}
|
||||
|
||||
$booking->status = 7; // processing transfer
|
||||
$booking->admin_status = 6; // upload china bankslip
|
||||
|
||||
|
||||
if($booking->save()){
|
||||
return response()->json(['message'=>"Success"],200);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,4 +7,8 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class Invoice extends Model
|
||||
{
|
||||
protected $fillable = ['invoice_url','amount','booking_id'];
|
||||
|
||||
public function booking(){
|
||||
return $this->hasOne('App\Booking');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user