mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim-api.git
synced 2026-08-31 18:34:14 +00:00
added migration, model, controller for the shipment arrangement
This commit is contained in:
@@ -14,4 +14,9 @@ class Company extends Model
|
||||
{
|
||||
return $this->belongsTo('App\User');
|
||||
}
|
||||
|
||||
public function shipment()
|
||||
{
|
||||
return $this->hasOne('App\Shipment');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Customexam extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'so_id',
|
||||
'custom_date',
|
||||
'new_etd',
|
||||
'new_eta',
|
||||
'release_date',
|
||||
];
|
||||
|
||||
public function so()
|
||||
{
|
||||
return $this->hasOne('App\Shipment');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Shipment;
|
||||
use App\Shipmentitem;
|
||||
use App\Customexam;
|
||||
use App\So;
|
||||
|
||||
class ShipmentarrangementController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the shipment arrangement
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$shipment = new Shipment;
|
||||
$shipment->loading_date = $request->input('loading_date');
|
||||
$shipment->shipment_no = $request->input('shipment_no');
|
||||
$shipment->departure_port = $request->input('departure_port');
|
||||
$shipment->container_no = $request->input('container_no');
|
||||
$shipment->type_of_container = $request->input('type_of_container');
|
||||
$shipment->last_etd = $request->input('last_etd');
|
||||
$shipment->last_eta = $request->input('last_eta');
|
||||
$shipment->driver_name = $request->input('driver_name');
|
||||
$shipment->driver_contact_no = $request->input('driver_contact_no');
|
||||
$shipment->trailer_no = $request->input('trailer_no');
|
||||
$shipment->driver_ic_no = $request->input('driver_ic_no');
|
||||
$shipment->loading_address = $request->input('loading_address');
|
||||
$shipment->loading_city = $request->input('loading_city');
|
||||
$shipment->loading_state = $request->input('loading_state');
|
||||
$shipment->contact_no = $request->input('contact_no');
|
||||
$shipment->country = $request->input('country');
|
||||
$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->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();
|
||||
}
|
||||
|
||||
return response()->json(['shipment'=>$shipment], 201);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the Custom-examination
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function customStore(Request $request)
|
||||
{
|
||||
$customexam = new Customexam;
|
||||
$customexam->so_id = $request->input('so_id');
|
||||
$customexam->custom_date = $request->input('custom_date');
|
||||
$customexam->new_etd = $request->input('new_etd');
|
||||
$customexam->new_eta = $request->input('new_eta');
|
||||
$customexam->release_date = $request->input('release_date');
|
||||
$customexam->save();
|
||||
|
||||
return response()->json(['customexam'=>$customexam], 201);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Custom-examination.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function customUpdate(Request $request, $id)
|
||||
{
|
||||
|
||||
$customexam = Customexam::find($id);
|
||||
$customexam->so_id = $request->input('so_id');
|
||||
$customexam->custom_date = $request->input('custom_date');
|
||||
$customexam->new_etd = $request->input('new_etd');
|
||||
$customexam->new_eta = $request->input('new_eta');
|
||||
$customexam->release_date = $request->input('release_date');
|
||||
$customexam->save();
|
||||
|
||||
return response()->json(['customexam'=>$customexam], 201);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Shipment arrangement.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$shipment = Shipment::find($id);
|
||||
$shipment->loading_date = $request->input('loading_date');
|
||||
$shipment->shipment_no = $request->input('shipment_no');
|
||||
$shipment->departure_port = $request->input('departure_port');
|
||||
$shipment->container_no = $request->input('container_no');
|
||||
$shipment->type_of_container = $request->input('type_of_container');
|
||||
$shipment->last_etd = $request->input('last_etd');
|
||||
$shipment->last_eta = $request->input('last_eta');
|
||||
$shipment->driver_name = $request->input('driver_name');
|
||||
$shipment->driver_contact_no = $request->input('driver_contact_no');
|
||||
$shipment->trailer_no = $request->input('trailer_no');
|
||||
$shipment->driver_ic_no = $request->input('driver_ic_no');
|
||||
$shipment->loading_address = $request->input('loading_address');
|
||||
$shipment->loading_city = $request->input('loading_city');
|
||||
$shipment->loading_state = $request->input('loading_state');
|
||||
$shipment->contact_no = $request->input('contact_no');
|
||||
$shipment->country = $request->input('country');
|
||||
$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->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();
|
||||
|
||||
}
|
||||
|
||||
return response()->json(['shipment'=>$shipment], 201);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,7 +46,7 @@ class WarehousearrangementController extends Controller
|
||||
$warehouseitems = $request->input("warehouseitem");
|
||||
foreach ($warehouseitems as $warehouseitem)
|
||||
{
|
||||
|
||||
|
||||
$new_warehouseitem = new Warehouseitem(array(
|
||||
'description'=>$warehouseitem['description'],
|
||||
'nominal_ctn'=>$warehouseitem['nominal_ctn'],
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Shipment extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'loading_date',
|
||||
'shipment_no',
|
||||
'departure_port',
|
||||
'container_no',
|
||||
'type_of_container',
|
||||
'last_etd',
|
||||
'last_eta',
|
||||
'driver_name',
|
||||
'driver_contact_no',
|
||||
'trailer_no',
|
||||
'driver_ic_no',
|
||||
'loading_address',
|
||||
'loading_city',
|
||||
'loading_state',
|
||||
'contact_no',
|
||||
'country',
|
||||
'contact_person',
|
||||
'remark',
|
||||
'so_id',
|
||||
'com_id',
|
||||
];
|
||||
|
||||
|
||||
public function shipmentitem()
|
||||
{
|
||||
return $this->hasMany('App\Shipmentitem');
|
||||
}
|
||||
|
||||
public function so()
|
||||
{
|
||||
return $this->belongsTo('App\So');
|
||||
}
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->hasOne('App\Company');
|
||||
}
|
||||
|
||||
public function Customexam()
|
||||
{
|
||||
return $this->hasOne('App\Customexam');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Shipmentitem extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'so_id',//shipping order
|
||||
'sa_id',//shipment arrangement
|
||||
];
|
||||
|
||||
public function so()
|
||||
{
|
||||
return $this->belongsTo('App\So');
|
||||
}
|
||||
|
||||
public function shipment()
|
||||
{
|
||||
return $this->belongsTo('App\Shipment');
|
||||
}
|
||||
}
|
||||
+11
-1
@@ -19,10 +19,20 @@ class So extends Model
|
||||
{
|
||||
return $this->hasMany('App\Soitem');
|
||||
}
|
||||
public function warehousearr()
|
||||
|
||||
public function warehousearr()
|
||||
{
|
||||
return $this->hasMany('App\Warehousearr');
|
||||
}
|
||||
|
||||
public function shipment()
|
||||
{
|
||||
return $this->hasMany('App\Shipment');
|
||||
}
|
||||
|
||||
public function shipmentitem()
|
||||
{
|
||||
return $this->hasMany('App\Shipmentitem');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class DropForeignKeyInWarehouseitemsTable extends Migration
|
||||
//
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateShipmentsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('shipments', function (Blueprint $table) {
|
||||
|
||||
//shipment details
|
||||
$table->increments('id');
|
||||
$table->date('loading_date');
|
||||
$table->string('shipment_no');
|
||||
$table->string('departure_port');
|
||||
$table->string('container_no');
|
||||
$table->string('type_of_container');
|
||||
$table->date('last_etd');
|
||||
$table->date('last_eta');
|
||||
|
||||
//loading vehicle n driver
|
||||
$table->string('driver_name');
|
||||
$table->integer('driver_contact_no');
|
||||
$table->string('trailer_no');
|
||||
$table->string('driver_ic_no');
|
||||
|
||||
//loading venue
|
||||
$table->string('loading_address');
|
||||
$table->string('loading_city');
|
||||
$table->string('loading_state');
|
||||
$table->integer('contact_no');
|
||||
$table->string('country');
|
||||
$table->string('contact_person');
|
||||
$table->longText('remark');
|
||||
$table->unsignedInteger('so_id');
|
||||
$table->foreign('so_id')
|
||||
->references('id')->on('sos')
|
||||
->onDelete('cascade');
|
||||
$table->unsignedInteger('com_id');
|
||||
$table->foreign('com_id')
|
||||
->references('id')->on('companies')
|
||||
->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('shipments');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateShipmentitemsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('shipmentitems', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('so_id');
|
||||
$table->foreign('so_id')
|
||||
->references('id')->on('sos')
|
||||
->onDelete('cascade');
|
||||
$table->unsignedInteger('sa_id');
|
||||
$table->foreign('sa_id')
|
||||
->references('id')->on('shipments')
|
||||
->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('shipmentitems');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateCustomexamsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('customexams', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('so_id');
|
||||
$table->foreign('so_id')
|
||||
->references('id')->on('sos')
|
||||
->onDelete('cascade');
|
||||
$table->date('custom_date');
|
||||
$table->date('new_etd');
|
||||
$table->date('new_eta');
|
||||
$table->date('release_date');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('customexams');
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ class SoSeeder extends Seeder
|
||||
{
|
||||
DB::table('sos')->insert([
|
||||
|
||||
'id' => '99',
|
||||
'id' => '1',
|
||||
'ff_id' => '1',
|
||||
'supplier_company_name' => 'SEED',
|
||||
'supplier_contact_person' => 'SEED',
|
||||
|
||||
@@ -18,7 +18,7 @@ class SoitemSeeder extends Seeder
|
||||
|
||||
([
|
||||
|
||||
'so_id' => '99',
|
||||
'so_id' => '1',
|
||||
'status' => '1',
|
||||
'order_id' => '1',
|
||||
'brand_no' => '1',
|
||||
@@ -39,7 +39,7 @@ class SoitemSeeder extends Seeder
|
||||
]),
|
||||
([
|
||||
|
||||
'so_id' => '99',
|
||||
'so_id' => '1',
|
||||
'status' => '0',
|
||||
'order_id' => '1',
|
||||
'brand_no' => '1',
|
||||
|
||||
@@ -15,7 +15,7 @@ class WarehousearrSeeder extends Seeder
|
||||
{
|
||||
DB::table('warehousearrs')->insert([
|
||||
|
||||
'so_id' => '99',
|
||||
'so_id' => '1',
|
||||
'receive_on'=> Carbon::now()->format('Y-m-d H:i:s'),
|
||||
'transport_company_name'=> 'TEScief',
|
||||
'consignment_note_no'=> '1',
|
||||
|
||||
+13
-1
@@ -34,7 +34,19 @@ Route::post('/warehousearr/warehouse_picture/{wa_id}','WarehousearrangementContr
|
||||
Route::post('/warehousearr/warehouse_item_picture/{wa_id}','WarehousearrangementController@warehouseitempic');//upload warehousepicture picture
|
||||
Route::put('/warehousearr/{wa_id}','WarehousearrangementController@update');//update the wrn
|
||||
Route::post('/decision','WarehousearrangementController@storedecision');//decision reject and request the wrn
|
||||
Route::post('/decision/decisionitem','WarehousearrangementController@storedecisionitem');//decision item for reject and request
|
||||
Route::post('/decision/decisionitem','WarehousearrangementController@storedecisionitem');//decision item for reject and request
|
||||
|
||||
|
||||
|
||||
/* Shipment-arrangement */
|
||||
Route::get('/shipment','ShipmentarrangementController@index');//view the shipment
|
||||
Route::post('/shipment','ShipmentarrangementController@store');//post the shipment
|
||||
//update shipment??
|
||||
Route::post('/custom-exam','ShipmentarrangementController@customStore');;//post the custom-examintion
|
||||
Route::put('/custom-exam','ShipmentarrangementController@customUpdate');//update the custom-examintion
|
||||
|
||||
|
||||
|
||||
|
||||
/* Authentication */
|
||||
Route::post('login', 'AuthController@login');
|
||||
|
||||
Reference in New Issue
Block a user