From 94b664bb457b82793eefb36e91dc0adeef94ae3a Mon Sep 17 00:00:00 2001 From: Nazri Hamzah Date: Sat, 30 Jun 2018 16:13:26 +0800 Subject: [PATCH] show current rate api --- app/Http/Controllers/RateController.php | 12 +++++++----- routes/api.php | 7 ++++--- tests/Feature/RateTest.php | 11 +++++++++-- vendor/composer/autoload_static.php | 8 ++++---- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/app/Http/Controllers/RateController.php b/app/Http/Controllers/RateController.php index 67f3bddb..acd0f46e 100644 --- a/app/Http/Controllers/RateController.php +++ b/app/Http/Controllers/RateController.php @@ -12,11 +12,6 @@ class RateController extends Controller return Rate::all(); } - public function show(Rate $rate) - { - return $rate; - } - public function store(Request $request) { $rate = Rate::create($request->all()); @@ -37,4 +32,11 @@ class RateController extends Controller return response()->json(null, 204); } + + public function show() + { + $rate = DB::table('rates')->latest()->first(); + + return response()->json($rate, 200); + } } \ No newline at end of file diff --git a/routes/api.php b/routes/api.php index 7c02d29d..d3edcb5f 100644 --- a/routes/api.php +++ b/routes/api.php @@ -69,8 +69,9 @@ Route::group(['middleware' => ['role:admin']], function() { Route::put('update-rate/{rate}', 'RateController@update'); Route::delete('update-rate/{rate}', 'RateController@delete'); Route::get('update-rate', 'RateController@index'); - Route::get('update-rate/{rate}', 'RateController@show'); - + + //show current rate + Route::get('rate', 'RateController@show'); Route::get('setting-credit', 'SettingCreditController@index'); Route::get('setting-credit/{credit}', 'SettingCreditController@show'); @@ -106,7 +107,7 @@ Route::group(['middleware' => ['role:admin']], function() { Route::patch('/booking/{id}/update-china-bankslip','ChinaBankSlipController@update'); Route::get('/booking/{id}/po', 'BookingController@showPurchaseOrder'); Route::post('booking/{id}/upload-invoice', 'BookingController@uploadInvoice'); - Route::post('booking/{id}/confirm-invoice', 'BookingController@confirmInvoice'); + Route::post('booking/{id}/confirm-invoice', 'BookingController@confirmInvoice'); }); diff --git a/tests/Feature/RateTest.php b/tests/Feature/RateTest.php index bd2a73ce..8cc829de 100644 --- a/tests/Feature/RateTest.php +++ b/tests/Feature/RateTest.php @@ -43,8 +43,8 @@ class RateTest extends TestCase 'x2_ba' => '1.2' ]) ->assertStatus(201); - } - + } + public function testUpdate(){ $response = $this->actingAs($this->user) @@ -57,5 +57,12 @@ class RateTest extends TestCase 'x2_ba' => '1.2' ]) ->assertStatus(200); + } + + public function testShowRate(){ + $response = $this->json('GET', '/api/rate'); + $response + ->assertStatus(200); } + } diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 0238e370..93444711 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -12,11 +12,11 @@ class ComposerStaticInit186bbd0d0f979469b3a193511536d69e '25072dd6e2470089de65ae7bf11d3109' => __DIR__ . '/..' . '/symfony/polyfill-php72/bootstrap.php', '667aeda72477189d0494fecd327c3641' => __DIR__ . '/..' . '/symfony/var-dumper/Resources/functions/dump.php', '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php', - '2c102faa651ef8ea5874edb585946bce' => __DIR__ . '/..' . '/swiftmailer/swiftmailer/lib/swift_required.php', 'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php', + '2c102faa651ef8ea5874edb585946bce' => __DIR__ . '/..' . '/swiftmailer/swiftmailer/lib/swift_required.php', 'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php', - '5255c38a0faeba867671b61dfda6d864' => __DIR__ . '/..' . '/paragonie/random_compat/lib/random.php', '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php', + '5255c38a0faeba867671b61dfda6d864' => __DIR__ . '/..' . '/paragonie/random_compat/lib/random.php', 'bd9634f2d41831496de0d3dfe4c94881' => __DIR__ . '/..' . '/symfony/polyfill-php56/bootstrap.php', 'f0906e6318348a765ffb6eb24e0d0938' => __DIR__ . '/..' . '/laravel/framework/src/Illuminate/Foundation/helpers.php', '58571171fd5812e6e447dce228f52f4d' => __DIR__ . '/..' . '/laravel/framework/src/Illuminate/Support/helpers.php', @@ -145,8 +145,8 @@ class ComposerStaticInit186bbd0d0f979469b3a193511536d69e 'phpDocumentor\\Reflection\\' => array ( 0 => __DIR__ . '/..' . '/phpdocumentor/reflection-common/src', - 1 => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src', - 2 => __DIR__ . '/..' . '/phpdocumentor/reflection-docblock/src', + 1 => __DIR__ . '/..' . '/phpdocumentor/reflection-docblock/src', + 2 => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src', ), 'Zizaco\\Entrust\\' => array (