fix merge problem, create factory, fix controller problem in SO and WRN, setup a testing database

This commit is contained in:
Zain Fauzan Rofie Azizi
2018-05-31 15:59:59 +08:00
17 changed files with 658 additions and 25 deletions
+25
View File
@@ -0,0 +1,25 @@
<?php
use Faker\Generator as Faker;
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/
// Manually creating the relationship tree.
$factory->define(App\So::class, function (Faker $faker) {
return [
'ff_id'=>'testing',
'supplier_company_name'=>'testing',
'supplier_contact_person'=>'testing',
'supplier_contact_person_no'=>'12345',
'delivery_id'=>'12345',
'warehouse_id'=>'testing',
];
});
@@ -0,0 +1,44 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateSosTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('sos', function (Blueprint $table) {
$table->increments('id');
//Order details
$table->integer('ff_id');
$table->string('supplier_company_name');
$table->string('supplier_contact_person');
$table->integer('supplier_contact_person_no');
//Delivery details
$table->integer('delivery_id');
//Warehouse details
$table->integer('warehouse_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('sos');
}
}
@@ -0,0 +1,59 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateSoitemsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('soitems', function (Blueprint $table) {
$table->increments('id');
// foreign key for the so table
$table->unsignedInteger('so_id');
$table->foreign('so_id')
->references('id')->on('sos')
->onDelete('cascade')
->onUpdate('cascade');
$table->Integer('status')->default('0');
//Item details
$table->integer('order_id');
$table->integer('brand_no');
$table->integer('model_no');
$table->integer('item_code');
$table->string('quantity_of_item');
$table->string('uom');
//Packaging details
$table->integer('quantity_of_carton');
$table->string('packaging_type');
//Measurement details
$table->double('packaging_height');
$table->double('packaging_width');
$table->double('packaging_depth');
//Weight details
$table->double('packaging_gross');
$table->double('packaging_nett');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('soitems');
}
}
@@ -27,8 +27,8 @@ class DropForeignKeyInWarehouseitemsTable extends Migration
{
Schema::table('warehouseitems', function (Blueprint $table) {
// $table->dropColumn('soitem_id');
// $table->dropForeign('warehouseitems_soitem_id_foreign');
$table->dropColumn('soitem_id');
$table->dropForeign('warehouseitems_soitem_id_foreign');
});
}
+2
View File
@@ -13,5 +13,7 @@ class DatabaseSeeder extends Seeder
{
$this->call(LaratrustSeeder::class);
$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([
'ff_id' => '1',
'supplier_company_name' => 'SEED',
'supplier_contact_person' => 'SEED',
'supplier_contact_person_no' => '1234',
'delivery_id' => '1',
'warehouse_id' => '1',
'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([
([
'so_id' => '3',
'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' => '3',
'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'),
]),
]);
}
}