mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 12:24:09 +00:00
Add controller and table for marking
This commit is contained in:
@@ -109,25 +109,25 @@ class BookingController extends Controller
|
||||
// The test failed due to ->save() before filling up the information at below
|
||||
|
||||
// TODO : handle RMB, MYR and USD (we can use exchange type: USDtoMYR, RMBtoMYR vise versa to switch case)
|
||||
// $booking->rmb_book_pay_method = $request->input('payment_method');
|
||||
// $booking->rmb_book_account_name = $request->input('rmb_book_account_name');
|
||||
// $booking->rmb_book_acc_no = $request->input('rmb_book_acc_no');
|
||||
// $booking->rmb_book_bank_branch = $request->input('rmb_book_bank_branch');
|
||||
// $booking->company_name = $request->input('company_name');
|
||||
// $booking->company_address = $request->input('company_address');
|
||||
// $booking->bank_address = $request->input('bank_address');
|
||||
// $booking->swift_code = $request->input('swift_code');
|
||||
// $booking->cnap = $request->input('cnap');
|
||||
// $booking->term = $request->input('term');
|
||||
$booking->rmb_book_pay_method = $request->input('payment_method');
|
||||
$booking->rmb_book_account_name = $request->input('rmb_book_account_name');
|
||||
$booking->rmb_book_acc_no = $request->input('rmb_book_acc_no');
|
||||
$booking->rmb_book_bank_branch = $request->input('rmb_book_bank_branch');
|
||||
$booking->company_name = $request->input('company_name');
|
||||
$booking->company_address = $request->input('company_address');
|
||||
$booking->bank_address = $request->input('bank_address');
|
||||
$booking->swift_code = $request->input('swift_code');
|
||||
$booking->cnap = $request->input('cnap');
|
||||
$booking->term = $request->input('term');
|
||||
|
||||
// $booking->usd_book_amount = $request->input('usd_book_amount');
|
||||
// $booking->usd_book_pay_method = $request->input('usd_book_pay_method');
|
||||
// $booking->usd_book_company_name = $request->input('usd_book_company_name');
|
||||
// $booking->usd_book_company_address = $request->input('usd_book_company_address');
|
||||
// $booking->usd_book_swift_code = $request->input('usd_book_swift_code');
|
||||
// $booking->usd_book_cnap = $request->input('usd_book_cnap');
|
||||
// $booking->usd_book_bank_branch = $request->input('usd_book_bank_branch');
|
||||
// $booking->verification_status = $request->input('verification_status');
|
||||
$booking->usd_book_amount = $request->input('usd_book_amount');
|
||||
$booking->usd_book_pay_method = $request->input('usd_book_pay_method');
|
||||
$booking->usd_book_company_name = $request->input('usd_book_company_name');
|
||||
$booking->usd_book_company_address = $request->input('usd_book_company_address');
|
||||
$booking->usd_book_swift_code = $request->input('usd_book_swift_code');
|
||||
$booking->usd_book_cnap = $request->input('usd_book_cnap');
|
||||
$booking->usd_book_bank_branch = $request->input('usd_book_bank_branch');
|
||||
$booking->verification_status = $request->input('verification_status');
|
||||
$booking->save();
|
||||
return response()->json($booking, 201);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Marking;
|
||||
|
||||
class MarkingController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return Marking::all();
|
||||
}
|
||||
|
||||
public function show(Marking $marking)
|
||||
{
|
||||
return $marking;
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$marking = Marking::create($request->all());
|
||||
|
||||
return response()->json($marking, 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, Marking $marking)
|
||||
{
|
||||
$marking->update($request->all());
|
||||
|
||||
return response()->json($marking, 200);
|
||||
}
|
||||
|
||||
public function delete(Marking $marking)
|
||||
{
|
||||
$marking->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Marking extends Model
|
||||
{
|
||||
protected $fillable = ['email','marking'];
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateMarkingTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('markings', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('email')->unique();
|
||||
$table->string('marking')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('marking');
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -81,8 +81,13 @@ Route::group(['middleware' => 'role:admin'], function() {
|
||||
Route::post('setting-beneficiary', 'SettingBeneficiaryController@store');
|
||||
Route::put('setting-beneficiary/{beneficiary}', 'SettingBeneficiaryController@update');
|
||||
Route::delete('setting-beneficiary/{beneficiary}', 'SettingBeneficiaryController@delete');
|
||||
});
|
||||
|
||||
Route::get('marking', 'MarkingController@index');
|
||||
Route::get('marking/{beneficiary}', 'MarkingController@show');
|
||||
Route::put('marking/{beneficiary}', 'MarkingController@update');
|
||||
Route::delete('marking/{beneficiary}', 'MarkingController@delete');
|
||||
});
|
||||
Route::post('marking', 'MarkingController@store');
|
||||
|
||||
Route::get('update-rate', 'RateController@index');
|
||||
Route::get('update-rate/{rate}', 'RateController@show');
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use App\User;
|
||||
use App\Role;
|
||||
use Artisan;
|
||||
|
||||
class MarkingTest extends TestCase
|
||||
{
|
||||
protected $user;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
Artisan::call('db:seed');
|
||||
|
||||
$this->user = factory(User::class)->create();
|
||||
$this->user->attachRole(Role::Where('name','admin')->first());
|
||||
}
|
||||
|
||||
public function testStore(){
|
||||
$response =
|
||||
$this->actingAs($this->user)
|
||||
->postJson('/api/marking/',[
|
||||
'email' => 'user@example.com',
|
||||
'marking' => 'markingcode123'
|
||||
])
|
||||
->assertStatus(201);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user