mirror of
https://gitlab.com/omair-personal/exchange.git
synced 2026-08-19 04:24:08 +00:00
Reject user bank slip with reason. Add migration for userbankslip.
This commit is contained in:
@@ -249,9 +249,40 @@ class BookingController extends Controller
|
||||
return response()->json(['message'=>'Access denied'], 200);
|
||||
}
|
||||
|
||||
// Rejected bankslip cannot be approve again
|
||||
if($userBankSlip->is_reject == 1)
|
||||
{
|
||||
return response()->json(['message'=>'Bankslip already rejected'],200);
|
||||
}
|
||||
|
||||
$userBankSlip->is_approve = 1;
|
||||
$userBankSlip->save();
|
||||
return response()->json(['message'=>'Success'],200);
|
||||
}
|
||||
|
||||
public function rejectBankSlip(Request $request, $book_id)
|
||||
{
|
||||
if (!$Booking = Booking::where('user_id',Auth::user()->id)->where('id',$book_id)->first())
|
||||
{
|
||||
return response()->json(['message'=>'Access denied'], 200);
|
||||
}
|
||||
|
||||
if(!$userBankSlip = UserBankSlip::where('book_id',$Booking->id)->first())
|
||||
{
|
||||
return response()->json(['message'=>'Access denied'], 200);
|
||||
}
|
||||
|
||||
// approved bankslip cannot be reject again
|
||||
if($userBankSlip->is_approve == 1)
|
||||
{
|
||||
return response()->json(['message'=>'Bankslip already approved'],200);
|
||||
}
|
||||
|
||||
$userBankSlip->is_reject = 1;
|
||||
$userBankSlip->reject_reason = $request->reject_reason;
|
||||
$userBankSlip->save();
|
||||
|
||||
return response()->json(['message'=>'Success'],200);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddRejectUserBankSlipTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('user_bank_slips', function (Blueprint $table) {
|
||||
$table->boolean('is_reject')->default('0');
|
||||
$table->string('reject_reason')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
if (Schema::hasColumn('user_bank_slips', 'is_reject')) {
|
||||
Schema::table('user_bank_slips', function (Blueprint $table) {
|
||||
// $table->dropColumn('is_reject');
|
||||
// $table->dropColumn('reject_reason');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,6 +81,7 @@ Route::delete('setting-supplier/{supplier}', 'SettingSupplierController@delete')
|
||||
|
||||
Route::post('upload-china-bankslip', 'ChinaBankSlipController@store');
|
||||
|
||||
Route::post('booking/{book_id}/reject-bank-slip','BookingController@rejectBankSlip');
|
||||
Route::post('booking/{book_id}/approve-bank-slip','BookingController@approveBankSlip');
|
||||
Route::post('booking/{book_id}/cancel', 'BookingController@cancel');
|
||||
Route::post('booking/{id}/upload-user-bankslip', 'BookingController@uploadbankslip');
|
||||
|
||||
@@ -117,4 +117,14 @@ class BookingTest extends TestCase
|
||||
->json('POST','/api/booking/' . $this->booking->id . '/approve-bank-slip', [])
|
||||
->assertSuccessful();
|
||||
}
|
||||
|
||||
|
||||
public function testRejectBankSlip()
|
||||
{
|
||||
$this->actingAs($this->user)
|
||||
->json('POST','/api/booking/' . $this->booking->id . '/reject-bank-slip', [
|
||||
'reject_reason' => 'Amount no enough'
|
||||
])
|
||||
->assertSuccessful();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user