diff --git a/app/Http/Controllers/ShipmentarrangementController.php b/app/Http/Controllers/ShipmentarrangementController.php index 072b5bf..c197133 100644 --- a/app/Http/Controllers/ShipmentarrangementController.php +++ b/app/Http/Controllers/ShipmentarrangementController.php @@ -11,13 +11,13 @@ use App\So; class ShipmentarrangementController extends Controller { /** - * Display a listing of the resource. + * Display a index of the shipment arrangement * * @return \Illuminate\Http\Response */ public function index() { - // + return view('welcome'); } /** @@ -48,19 +48,19 @@ class ShipmentarrangementController extends Controller $shipment->contact_person = $request->input('contact_person'); $shipment->remark = $request->input('remark'); $shipment->so_id = $request->input('so_id'); - $shipment->com_id = $request->input('com_id'); + $shipment->com_id = $Auth::user()->company()->id; $shipment->save(); //shipment item arrangement checkboxes //id=si1,si2,si3.... //name=shipmentbox[] - $shipmentitems = $request->input('shipmentitem'); - foreach ($shipmentitems as $shipmentitem) - { - $new_shipmentitem = new Shipmentitem; - $new_shipmentitem->shipmentbox = $shipmentitem; - $new_shipmentitem->save(); - } + // $shipmentitems = $request->input('shipmentitem'); + // foreach ($shipmentitems as $shipmentitem) + // { + // $new_shipmentitem = new Shipmentitem; + // $new_shipmentitem->shipmentbox = $shipmentitem; + // $new_shipmentitem->save(); + // } return response()->json(['shipment'=>$shipment], 201); @@ -141,15 +141,15 @@ class ShipmentarrangementController extends Controller $shipment->save(); - $shipmentitems = $request->input('shipmentitem'); - foreach ($shipmentitems as $shipmentitem) - { - $ex_shipmentitem = shipmentitem::where('sa_id', $id)->first(); - $ex_shipmentitem = new Shipmentitem; - $ex_shipmentitem->shipmentbox = $shipmentitem; - $ex_shipmentitem->save(); + // $shipmentitems = $request->input('shipmentitem'); + // foreach ($shipmentitems as $shipmentitem) + // { + // $ex_shipmentitem = shipmentitem::where('sa_id', $id)->get(); + // $ex_shipmentitem = new Shipmentitem; + // $ex_shipmentitem->shipmentbox = $shipmentitem; + // $ex_shipmentitem->save(); - } + // } return response()->json(['shipment'=>$shipment], 201); } diff --git a/database/factories/WarehousearrFactory.php b/database/factories/WarehousearrFactory.php deleted file mode 100644 index 8d7c8a5..0000000 --- a/database/factories/WarehousearrFactory.php +++ /dev/null @@ -1,62 +0,0 @@ -define(App\Warehousearr::class, function (Faker $faker) { - return [ - - 'so_id'=> function () { - - return factory(App\So::class)->create()->id; - - }, - 'receive_on'=> '2018-03-01', - 'transport_company_name'=> 'testing', - 'consignment_note_no'=> '1', - 'warehouse_receive_note_no'=> '1', - 'receiving_person'=> 'testing', - 'marking_number'=> '1', - 'image'=> 'testing.jpg', - 'warehouseitem' => [ - 0 => [ - 'description'=> 'testing', - 'nominal_ctn'=> '1', - 'actual_ctn'=> '1', - 'nominal_measurement'=> '1', - 'actual_measurement'=> '1', - 'nominal_weight'=> '1', - 'actual_weight'=> '1', - 'balance'=> '1', - 'isDamaged'=> '1', - 'status'=> 'testing', - 'image'=> 'testing.jpg', - 'wa_id'=> '1', - ], - 1 => [ - 'description'=> 'testing', - 'nominal_ctn'=> '1', - 'actual_ctn'=> '1', - 'nominal_measurement'=> '1', - 'actual_measurement'=> '1', - 'nominal_weight'=> '1', - 'actual_weight'=> '1', - 'balance'=> '2', - 'isDamaged'=> '1', - 'status'=> 'testing', - 'image'=> 'testing.jpg', - 'wa_id'=> '1', - ] - ] - ]; -}); diff --git a/database/seeds/CompanySeeder.php b/database/seeds/CompanySeeder.php new file mode 100644 index 0000000..9b460a4 --- /dev/null +++ b/database/seeds/CompanySeeder.php @@ -0,0 +1,36 @@ +insert([ + + 'id'=> '1', + 'company_name'=>'testing', + 'registration_no'=>'testing', + 'tax_no'=>'testing', + 'tel_no'=>'12345', + 'fax'=>'12345', + 'address'=>'testing', + 'city'=>'testing', + 'postcode'=>'1234', + 'state'=>'testing', + 'country'=>'testing', + 'contact_person'=>'testing', + 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), + 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'), + 'user_id'=>'2', + + ]); + } +} diff --git a/database/seeds/CustomexamSeeder.php b/database/seeds/CustomexamSeeder.php new file mode 100644 index 0000000..1f4bcba --- /dev/null +++ b/database/seeds/CustomexamSeeder.php @@ -0,0 +1,27 @@ +insert([ + + 'id' => '1', + 'so_id' => '1', + 'custom_date' => Carbon::now()->format('Y-m-d H:i:s'), + 'new_etd' => Carbon::now()->format('Y-m-d H:i:s'), + 'new_eta' => Carbon::now()->format('Y-m-d H:i:s'), + 'release_date' => Carbon::now()->format('Y-m-d H:i:s'), + 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), + 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'), + + ]); + } +} diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index b2b7592..c4f70f4 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -17,5 +17,7 @@ class DatabaseSeeder extends Seeder $this->call(SoitemSeeder::class); $this->call(WarehousearrSeeder::class); $this->call(WarehouseitemSeeder::class); + $this->call(ShipmentArrangementSeeder::class); + $this->call(CustomexamSeeder::class); } } diff --git a/database/seeds/ShipmentArrangementSeeder.php b/database/seeds/ShipmentArrangementSeeder.php new file mode 100644 index 0000000..1b56e64 --- /dev/null +++ b/database/seeds/ShipmentArrangementSeeder.php @@ -0,0 +1,43 @@ +insert([ + + 'loading_date'=> Carbon::now()->format('Y-m-d H:i:s'), + 'shipment_no'=> '123213', + 'departure_port'=> 'TEST', + 'container_no'=> '12312', + 'type_of_container'=> 'TEST', + 'last_etd'=> Carbon::now()->format('Y-m-d H:i:s'), + 'last_eta'=> Carbon::now()->format('Y-m-d H:i:s'), + 'driver_name'=> 'TEST', + 'driver_contact_no'=> '1213', + 'trailer_no'=> '12324', + 'driver_ic_no'=> '12345', + 'loading_address'=> 'TEST', + 'loading_city'=> 'TEST', + 'loading_state'=> 'TEST', + 'contact_no'=> '12345', + 'country'=> 'TEST', + 'contact_person'=> 'TEST', + 'remark'=> 'TEST', + 'so_id'=> '1', + 'com_id'=> '1', + 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), + 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'), + + ]); + } +} diff --git a/database/seeds/SoSeeder.php b/database/seeds/SoSeeder.php index 9c4e1a3..06b5c50 100644 --- a/database/seeds/SoSeeder.php +++ b/database/seeds/SoSeeder.php @@ -15,7 +15,6 @@ class SoSeeder extends Seeder { DB::table('sos')->insert([ - 'id' => '1', 'ff_id' => '1', 'supplier_company_name' => 'SEED', 'supplier_contact_person' => 'SEED', diff --git a/database/seeds/WarehousearrSeeder.php b/database/seeds/WarehousearrSeeder.php index 39d8a51..cb67ec4 100644 --- a/database/seeds/WarehousearrSeeder.php +++ b/database/seeds/WarehousearrSeeder.php @@ -11,7 +11,7 @@ class WarehousearrSeeder extends Seeder * * @return void */ - public function run() + public function run() { DB::table('warehousearrs')->insert([ diff --git a/routes/api.php b/routes/api.php index c91c774..d3cd81f 100644 --- a/routes/api.php +++ b/routes/api.php @@ -41,9 +41,9 @@ Route::post('/decision/decisionitem','WarehousearrangementController@storedecisi /* Shipment-arrangement */ Route::get('/shipment','ShipmentarrangementController@index');//view the shipment Route::post('/shipment','ShipmentarrangementController@store');//post the shipment - //update shipment?? +Route::put('/shipment/{sa_id}','ShipmentarrangementController@update');//update shipment //update shipment?? Route::post('/custom-exam','ShipmentarrangementController@customStore');;//post the custom-examintion -Route::put('/custom-exam','ShipmentarrangementController@customUpdate');//update the custom-examintion +Route::put('/custom-exam/{id}','ShipmentarrangementController@customUpdate');//update the custom-examintion diff --git a/tests/Feature/CompanyTest.php b/tests/Feature/CompanyTest.php index 1a4a7fc..106722a 100644 --- a/tests/Feature/CompanyTest.php +++ b/tests/Feature/CompanyTest.php @@ -16,7 +16,7 @@ class CompanyTest extends TestCase protected $company; protected $user; - public function setUp() + public function setUp() { parent::setUp(); Artisan::call('db:seed'); diff --git a/tests/Unit/ShipmentArrangementTest.php b/tests/Unit/ShipmentArrangementTest.php new file mode 100644 index 0000000..8ae0788 --- /dev/null +++ b/tests/Unit/ShipmentArrangementTest.php @@ -0,0 +1,111 @@ +user = factory(User::class)->create(); + $this->company = $this->user->each(function ($u) { + factory(Company::class)->create([ + 'user_id' => $u->id, + ]); + }); + + } + + // public function testPOST() + // { + // $response = $this->json('POST', '/api/shipment', + + // [ + + // 'loading_date'=> '2018-06-05', + // 'shipment_no'=> '123213', + // 'departure_port'=> 'TEST', + // 'container_no'=> '12312', + // 'type_of_container'=> 'TEST', + // 'last_etd'=> '2018-06-05', + // 'last_eta'=> '2018-06-05', + // 'driver_name'=> 'TEST', + // 'driver_contact_no'=> '1213', + // 'trailer_no'=> '12324', + // 'driver_ic_no'=> '12345', + // 'loading_address'=> 'TEST', + // 'loading_city'=> 'TEST', + // 'loading_state'=> 'TEST', + // 'contact_no'=> '12345', + // 'country'=> 'TEST', + // 'contact_person'=> 'TEST', + // 'remark'=> 'TEST', + // 'so_id'=> '1', + // 'com_id'=> '1', + + // ]); + + // $response->assertStatus(201); + + // } + + +// public function testPUT() +// { +// $response = $this->json('PUT', '/api/shipment/1', + +// [ + +// 'loading_date'=> '2018-06-05', +// 'shipment_no'=> '123213', +// 'departure_port'=> 'TEST', +// 'container_no'=> '12312', +// 'type_of_container'=> 'TEST', +// 'last_etd'=> '2018-06-05', +// 'last_eta'=> '2018-06-05', +// 'driver_name'=> 'TEST', +// 'driver_contact_no'=> '1213', +// 'trailer_no'=> '12324', +// 'driver_ic_no'=> '12345', +// 'loading_address'=> 'TEST', +// 'loading_city'=> 'TEST', +// 'loading_state'=> 'TEST', +// 'contact_no'=> '12345', +// 'country'=> 'TEST', +// 'contact_person'=> 'TEST', +// 'remark'=> 'TEST', +// 'so_id'=> '1', +// 'com_id'=> '1', + +// ]); + +// $response->assertStatus(201); + + // } + + // public function testPUTcustom() + // { + // $response = $this->json('PUT', '/api/custom/1', + + // [ + // 'so_id' => '1', + // 'custom_date' => '2018-06-05', + // 'new_etd' => '2018-06-05', + // 'new_eta' => '2018-06-05', + // 'release_date' => '2018-06-05', + + // ]); + + // $response->assertStatus(201); + + // } +} diff --git a/tests/Unit/WarehouseReceiveNoteTest.php b/tests/Unit/WarehouseReceiveNoteTest.php index be57f41..0792621 100644 --- a/tests/Unit/WarehouseReceiveNoteTest.php +++ b/tests/Unit/WarehouseReceiveNoteTest.php @@ -14,7 +14,6 @@ use Artisan; class WarehouseReceiveNoteTest extends TestCase { - public function setUp() { @@ -29,7 +28,7 @@ class WarehouseReceiveNoteTest extends TestCase [ - 'so_id'=> '99', + 'so_id'=> '1', 'receive_on'=> '2018-06-04', 'transport_company_name'=> 'TESTTESTabc', 'consignment_note_no'=> '3',