added migration, model, and controller

This commit is contained in:
Zain Fauzan Rofie Azizi
2018-04-23 14:47:34 +08:00
parent 0a1f45d329
commit 4a8a075414
6 changed files with 95 additions and 1 deletions
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class DeliveryInfo extends Model
{
//
}
@@ -0,0 +1,32 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class DeliveryInfoController extends Controller
{
public function index()
{
return Product::all();
}
public function show(DeliveryInfo $deliveryinfo)
{
return $deliveryinfo;
}
public function store(DeliveryInfo $deliveryinfo)
{
$deliveryinfo = DeliveryInfot::create($request->all());
return response()->json(DeliveryInfo, 201);
}
public function delete(DeliveryInfo $deliveryinfo)
{
$deliveryinfo->delete();
return response()->json(null, 204);
}
}
+2 -1
View File
@@ -3,6 +3,7 @@
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
class AppServiceProvider extends ServiceProvider
{
@@ -13,7 +14,7 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot()
{
//
Schema::defaultStringLength(191);
}
/**
@@ -0,0 +1,40 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateDeliveryInfosTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('delivery_infos', function (Blueprint $table) {
$table->increments('id');
$table->string('branch');
$table->string('deli_info');
$table->string('address');
$table->string('city');
$table->integer('postcode');
$table->string('state');
$table->string('country');
$table->string('contact_person');
$table->integer('contact_person_no');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('delivery_infos');
}
}
+8
View File
@@ -16,3 +16,11 @@ use Illuminate\Http\Request;
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
Route::get('/api/company/del-info','DeliveryInfo@show');
Route::post('/api/company/{com-id}/del-info', 'DeliveryInfo@store');
Route::delete('/api/company/{com-id}/del-info', 'DeliveryInfo@delete');
+3
View File
@@ -14,3 +14,6 @@
Route::get('/', function () {
return view('welcome');
});