added credit limit seeder, it causes error when creating booking

This commit is contained in:
Jack Goh
2018-06-25 17:48:51 +08:00
parent 62d0d83cb6
commit ffe1023bba
3 changed files with 29 additions and 1 deletions
+6 -1
View File
@@ -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);
}
+22
View File
@@ -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'),
]);
}
}
+1
View File
@@ -16,5 +16,6 @@ class DatabaseSeeder extends Seeder
$this->call(UserRoleSeeder::class);
$this->call(RateTableSeeder::class);
$this->call(BookTableSeeder::class);
$this->call(CreditTableSeeder::class);
}
}