mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-27 00:04:10 +00:00
input data inside database using seeder
This commit is contained in:
+9
-1
@@ -23,7 +23,14 @@ class CreateBookingsTable extends Migration
|
||||
$table->string('company_address');
|
||||
$table->string('bank_address');
|
||||
$table->string('swift_code');
|
||||
$table->string('cnap');
|
||||
$table->string('cnap');
|
||||
$table->string('term');
|
||||
$table->double('amount');
|
||||
$table->unsignedInteger('rate_id');
|
||||
$table->foreign('rate_id')
|
||||
->references('id')->on('rates')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
@@ -36,5 +43,6 @@ class CreateBookingsTable extends Migration
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('bookings');
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class ChangeUserIdInBookingsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('bookings', function (Blueprint $table) {
|
||||
$table->unsignedInteger('user_id');
|
||||
$table->foreign('user_id')
|
||||
->references('id')->on('users')
|
||||
->onDelete('cascade');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class BookTableSeeder extends Seeder
|
||||
{
|
||||
@@ -11,6 +12,23 @@ class BookTableSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
//
|
||||
DB::table('bookings')->insert([
|
||||
// 'id' => '1',
|
||||
'account_name' => 'kazim',
|
||||
'account_num' => '1234',
|
||||
'bank_name' => 'maybank',
|
||||
'bank_branch' => 'rembau',
|
||||
'company_name' => 'ICEF',
|
||||
'company_address' => 'selangor',
|
||||
'bank_address' => 'cyber',
|
||||
'swift_code' => 'qwe123',
|
||||
'cnap' => '123asd',
|
||||
'term' => 'x1',
|
||||
'amount' => 1.2,
|
||||
'rate_id' => '1',
|
||||
'user_id' => '17',
|
||||
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
||||
'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ class DatabaseSeeder extends Seeder
|
||||
{
|
||||
$this->call(UsersTableSeeder::class);
|
||||
$this->call(RolesAndPermissionsSeeder::class);
|
||||
$this->call(RateTableSeeder::class);
|
||||
// $this->call(RateTableSeeder::class);
|
||||
$this->call('Database\Seeds\RateTableSeeder');
|
||||
$this->call('Database\Seeds\BookTableSeeder');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class RateTableSeeder extends Seeder
|
||||
{
|
||||
@@ -18,6 +19,19 @@ class RateTableSeeder extends Seeder
|
||||
'x2_cash' => 1.2,
|
||||
'x2_cheque' => 1.2,
|
||||
'x2_ba' => 1.2,
|
||||
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
||||
'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
DB::table('rates')->insert([
|
||||
'x1_cash' => 1.3,
|
||||
'x1_cheque' => 1.3,
|
||||
'x1_ba' => 1.3,
|
||||
'x2_cash' => 1.3,
|
||||
'x2_cheque' => 1.3,
|
||||
'x2_ba' => 1.3,
|
||||
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
||||
'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user