complete the model, controller, and migration

This commit is contained in:
Zain Fauzan Rofie Azizi
2018-05-15 12:13:06 +08:00
parent 6057f48d9e
commit 4d7b9b931f
4 changed files with 22 additions and 3 deletions
+5 -1
View File
@@ -7,7 +7,6 @@ use Illuminate\Database\Eloquent\Model;
class So extends Model
{
protected $fillable = [
'id',
'ff_id',
'supplier_company_name',
'supplier_contact_person',
@@ -16,4 +15,9 @@ class So extends Model
'warehouse_id',
];
public function Soitem()
{
return $this->hasMany(Soitem::class);
}
}
+8 -1
View File
@@ -7,7 +7,8 @@ use Illuminate\Database\Eloquent\Model;
class Soitem extends Model
{
protected $fillable = [
'id',
'so_id',
'status',
'order_id',
'brand_no',
'model_no',
@@ -24,4 +25,10 @@ class Soitem extends Model
];
public function So()
{
return $this->belongsTo(So::class);
}
}
@@ -16,6 +16,14 @@ 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')
->references('id')->on('sos')
->onDelete('cascade')
->onUpdate('cascade');
$table->Integer('status')->default('0');
//Item details
$table->integer('order_id');
$table->integer('brand_no');
+1 -1
View File
@@ -16,7 +16,7 @@ use Illuminate\Http\Request;
//Route for the shipping order
Route::get('/so', 'SoController@index');// get the list of the shipping order
Route::get('/so/{so_id}', 'SoController@so');//get the shipping order
Route::post('/so/{so_id}', 'SoController@store');//create shipping order
Route::post('/so/{so_id}', 'SoController@store');//store shipping order
Route::post('/so/{so_id}/cancel-order', 'SoController@cancelorder');//post the cancel order
Route::delete('/so/{so_id}', 'SoController@delete');// delete the shipping order
Route::put('/so/{so_id}', 'SoController@update');//update the shipping order