get_time_limit

This commit is contained in:
Too
2018-06-25 18:16:20 +08:00
parent a3d8eff9e0
commit 3129da5df4
4 changed files with 39 additions and 4 deletions
+4 -2
View File
@@ -29,7 +29,8 @@ class BookingController extends Controller
// set timeout
$date1 = new DateTime($booking->created_at);
$date2 = new DateTime();
$difference_in_seconds = ($date1->format('U') + 600) - ($date2->format('U'));
$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
@@ -79,7 +80,8 @@ class BookingController extends Controller
// set timeout
$date1 = new DateTime($booking->created_at);
$date2 = new DateTime();
$difference_in_seconds = ($date1->format('U') + 600) - ($date2->format('U'));
$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
+1 -1
View File
@@ -6,5 +6,5 @@ use Illuminate\Database\Eloquent\Model;
class SettingCredit extends Model
{
protected $fillable = ['rmb_credit_limit','usd_credit_limit'];
protected $fillable = ['rmb_credit_limit','usd_credit_limit','time_limit'];
}
+2 -1
View File
@@ -5,6 +5,7 @@ use Faker\Generator as Faker;
$factory->define(App\SettingCredit::class, function (Faker $faker) {
return [
'rmb_credit_limit' => $faker->randomDigit,
'usd_credit_limit' => $faker->randomDigit
'usd_credit_limit' => $faker->randomDigit,
'time_limit' => $faker->randomDigit
];
});
@@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddTimeLimitSettingCreditTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('setting_credits', function (Blueprint $table) {
$table->integer('time_limit');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('setting_credits', function (Blueprint $table) {
// $table->dropColumn('time_limit');
});
}
}