mirror of
https://gitlab.com/omair-personal/exchange.git
synced 2026-08-19 04:24:08 +00:00
added credit limit seeder, it causes error when creating booking
This commit is contained in:
@@ -165,7 +165,12 @@ class BookingController extends Controller
|
||||
$rates = Rate::orderby('updated_at','desc')->first();
|
||||
$term = $request->input('term');
|
||||
$amount = $request->input("amount"); // in RMB
|
||||
$creditLimit = SettingCredit::orderby('updated_at','desc')->first();
|
||||
$creditLimit = SettingCredit::orderby('updated_at','desc')->first();
|
||||
|
||||
if (!$creditLimit){
|
||||
return response()->json("Credit limit not set, please contact admin", 405);
|
||||
}
|
||||
|
||||
if($amount > $creditLimit->rmb_credit_limit){
|
||||
return response()->json("Exceed credit limit, need approved from admin", 401);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CreditTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('setting_credits')->insert([
|
||||
'rmb_credit_limit' => 20000,
|
||||
'usd_credit_limit' => 20000,
|
||||
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
||||
'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -16,5 +16,6 @@ class DatabaseSeeder extends Seeder
|
||||
$this->call(UserRoleSeeder::class);
|
||||
$this->call(RateTableSeeder::class);
|
||||
$this->call(BookTableSeeder::class);
|
||||
$this->call(CreditTableSeeder::class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user