can insert both so and soitem into db, but have an error

This commit is contained in:
Zain Fauzan Rofie Azizi
2018-05-21 17:01:07 +08:00
parent 137b9dc576
commit 0969c8647b
15 changed files with 229 additions and 89 deletions
@@ -15,7 +15,6 @@ class CreateSoitemsTable extends Migration
{
Schema::create('soitems', function (Blueprint $table) {
$table->increments('id');
// foreign key for the so table
$table->unsignedInteger('so_id');
$table->foreign('so_id')
+2 -1
View File
@@ -11,6 +11,7 @@ class DatabaseSeeder extends Seeder
*/
public function run()
{
// $this->call(UsersTableSeeder::class);
//$this->call(UsersTableSeeder::class);
$this->call(SoSeeder::class);
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Seeder;
use App\So;
use Carbon\Carbon;
class SoSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('sos')->insert([
// 'id' => '8',
'ff_id' => '4',
'supplier_company_name' => 'SEED',
'supplier_contact_person' => 'SEED',
'supplier_contact_person_no' => '1234',
'delivery_id' => '4',
'warehouse_id' => '4',
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
]);
}
}
+64
View File
@@ -0,0 +1,64 @@
<?php
use Illuminate\Database\Seeder;
use App\Soitems;
use Carbon\Carbon;
class SoitemSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('soitems')->insert([
([
// 'id' => '8',
'so_id' => '2',
'status' => '0',
'order_id' => '1',
'brand_no' => '1',
'model_no' => '1',
'item_code' => '1',
'quantity_of_item' => '1',
'uom' => 'SEED',
'quantity_of_carton' => '1',
'packaging_type' => '1',
'packaging_height' => '1',
'packaging_width' => '1',
'packaging_depth' => '1',
'packaging_gross' => '1',
'packaging_nett' => '41',
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
]),
([
// 'id' => '8',
'so_id' => '2',
'status' => '0',
'order_id' => '1',
'brand_no' => '1',
'model_no' => '1',
'item_code' => '1',
'quantity_of_item' => '1',
'uom' => 'SEED',
'quantity_of_carton' => '1',
'packaging_type' => '1',
'packaging_height' => '1',
'packaging_width' => '1',
'packaging_depth' => '1',
'packaging_gross' => '1',
'packaging_nett' => '41',
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
]),
]);
}
}