diff --git a/app/Booking.php b/app/Booking.php
index 6144528c..a991d1a1 100644
--- a/app/Booking.php
+++ b/app/Booking.php
@@ -8,4 +8,9 @@ class Booking extends Model
{
// protected $guarded = [];
protected $fillable = ['term', 'amount', 'rate_id', 'user_id', 'account_name', 'account_num', 'bank_name', 'bank_branch', 'company_name', 'company_address', 'bank_address', 'swift_code', 'cnap' ];
+ public $timestamps = true;
+ public function user(){
+ return $this->belongsTo('app\User');
+ }
}
+
diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php
index b7514b28..afa6ec6d 100644
--- a/app/Http/Controllers/BookingController.php
+++ b/app/Http/Controllers/BookingController.php
@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Booking;
use App\Rate;
+use App\User;
class BookingController extends Controller
{
@@ -63,11 +64,36 @@ class BookingController extends Controller
$rate = "no";
break;
}
- return $rate;
-
+
+ //Calculation part
+ // $bookings = Booking::all();
+ $amount = $request->input("amount");
+ $svcharge=20.00;
+ $bia = round(($amount + ($svcharge / $rate) + 0.06), 2);
+
+ // return $bia;
+ $user = User::first();
+ $booking = new Booking();
+ $booking->account_name = $request->input('account_name');
+ $booking->account_num = $request->input('account_num');
+ $booking->bank_name = $request->input('bank_name');
+ $booking->bank_branch = $request->input('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->amount = $request->input('amount');
+ $booking->rate_id = $rate;
+ // $booking->user()->associate($user);
+ $booking->user_id = $request->input('user_id');
+ $booking->bia = $bia;
+ $booking->save();
+
// return false;
//$booking = Booking::create($request->all());
- // return response()->json($booking, 201);
+ return response()->json($booking, 201);
}
diff --git a/app/User.php b/app/User.php
index 1d093208..4ceda42b 100644
--- a/app/User.php
+++ b/app/User.php
@@ -58,7 +58,7 @@ class User extends Authenticatable implements JWTSubject
*/
public function getRoleAttribute()
{
- return $this->roles->first()->name;
+ // return $this->roles->first()->name;
}
/**
@@ -98,4 +98,8 @@ class User extends Authenticatable implements JWTSubject
return [];
}
+ public function booking(){
+ return $this->hasMany('App\Booking');
+ }
+
}
diff --git a/composer.lock b/composer.lock
index fa74a2f6..50a353a1 100644
--- a/composer.lock
+++ b/composer.lock
@@ -706,16 +706,16 @@
},
{
"name": "laravel/framework",
- "version": "v5.6.21",
+ "version": "v5.6.22",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
- "reference": "458a89b1c5ff73072c27308566f444c790f76f28"
+ "reference": "637fd797a6dde8d24a9f07da77e375ec251c5d24"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laravel/framework/zipball/458a89b1c5ff73072c27308566f444c790f76f28",
- "reference": "458a89b1c5ff73072c27308566f444c790f76f28",
+ "url": "https://api.github.com/repos/laravel/framework/zipball/637fd797a6dde8d24a9f07da77e375ec251c5d24",
+ "reference": "637fd797a6dde8d24a9f07da77e375ec251c5d24",
"shasum": ""
},
"require": {
@@ -841,7 +841,7 @@
"framework",
"laravel"
],
- "time": "2018-05-08T13:30:15+00:00"
+ "time": "2018-05-15T13:34:20+00:00"
},
{
"name": "laravel/socialite",
@@ -907,16 +907,16 @@
},
{
"name": "laravel/tinker",
- "version": "v1.0.6",
+ "version": "v1.0.7",
"source": {
"type": "git",
"url": "https://github.com/laravel/tinker.git",
- "reference": "b22fe905fcefdffae76b011e27c7ac09e07e052b"
+ "reference": "e3086ee8cb1f54a39ae8dcb72d1c37d10128997d"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laravel/tinker/zipball/b22fe905fcefdffae76b011e27c7ac09e07e052b",
- "reference": "b22fe905fcefdffae76b011e27c7ac09e07e052b",
+ "url": "https://api.github.com/repos/laravel/tinker/zipball/e3086ee8cb1f54a39ae8dcb72d1c37d10128997d",
+ "reference": "e3086ee8cb1f54a39ae8dcb72d1c37d10128997d",
"shasum": ""
},
"require": {
@@ -966,7 +966,7 @@
"laravel",
"psysh"
],
- "time": "2018-04-16T12:10:37+00:00"
+ "time": "2018-05-17T13:42:07+00:00"
},
{
"name": "laravelcollective/html",
@@ -3157,34 +3157,39 @@
},
{
"name": "facebook/webdriver",
- "version": "1.5.0",
+ "version": "1.6.0",
"source": {
"type": "git",
"url": "https://github.com/facebook/php-webdriver.git",
- "reference": "86b5ca2f67173c9d34340845dd690149c886a605"
+ "reference": "bd8c740097eb9f2fc3735250fc1912bc811a954e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/facebook/php-webdriver/zipball/86b5ca2f67173c9d34340845dd690149c886a605",
- "reference": "86b5ca2f67173c9d34340845dd690149c886a605",
+ "url": "https://api.github.com/repos/facebook/php-webdriver/zipball/bd8c740097eb9f2fc3735250fc1912bc811a954e",
+ "reference": "bd8c740097eb9f2fc3735250fc1912bc811a954e",
"shasum": ""
},
"require": {
"ext-curl": "*",
+ "ext-json": "*",
+ "ext-mbstring": "*",
"ext-zip": "*",
"php": "^5.6 || ~7.0",
"symfony/process": "^2.8 || ^3.1 || ^4.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.0",
- "guzzle/guzzle": "^3.4.1",
- "php-coveralls/php-coveralls": "^1.0.2",
+ "jakub-onderka/php-parallel-lint": "^0.9.2",
+ "php-coveralls/php-coveralls": "^2.0",
"php-mock/php-mock-phpunit": "^1.1",
"phpunit/phpunit": "^5.7",
"sebastian/environment": "^1.3.4 || ^2.0 || ^3.0",
"squizlabs/php_codesniffer": "^2.6",
"symfony/var-dumper": "^3.3 || ^4.0"
},
+ "suggest": {
+ "ext-SimpleXML": "For Firefox profile creation"
+ },
"type": "library",
"extra": {
"branch-alias": {
@@ -3208,7 +3213,7 @@
"selenium",
"webdriver"
],
- "time": "2017-11-15T11:08:09+00:00"
+ "time": "2018-05-16T17:37:13+00:00"
},
{
"name": "filp/whoops",
diff --git a/database/migrations/2018_05_18_063200_add_bia_in_bookings_table.php b/database/migrations/2018_05_18_063200_add_bia_in_bookings_table.php
new file mode 100644
index 00000000..5c58ba83
--- /dev/null
+++ b/database/migrations/2018_05_18_063200_add_bia_in_bookings_table.php
@@ -0,0 +1,31 @@
+double('bia');
+
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ //
+ }
+}
diff --git a/database/seeds/BookTableSeeder.php b/database/seeds/BookTableSeeder.php
index a0f1e51f..27740fdd 100644
--- a/database/seeds/BookTableSeeder.php
+++ b/database/seeds/BookTableSeeder.php
@@ -14,8 +14,8 @@ class BookTableSeeder extends Seeder
{
DB::table('bookings')->insert([
// 'id' => '1',
- 'account_name' => 'kazim',
- 'account_num' => '1234',
+ 'account_name' => 'milah',
+ 'account_num' => '99898',
'bank_name' => 'maybank',
'bank_branch' => 'rembau',
'company_name' => 'ICEF',
@@ -26,7 +26,7 @@ class BookTableSeeder extends Seeder
'term' => 'x1',
'amount' => 1.2,
'rate_id' => '1',
- 'user_id' => '17',
+ 'user_id' => '3',
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
]);
diff --git a/phpunit.xml b/phpunit.xml
index 5341ea60..2a973817 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -27,12 +27,9 @@
-<<<<<<< HEAD
-=======
->>>>>>> 06aa931eb57dbc7c95748ade6e3bb659f0659abe
diff --git a/routes/api.php b/routes/api.php
index ebe30caf..bec708df 100644
--- a/routes/api.php
+++ b/routes/api.php
@@ -23,13 +23,9 @@ Route::middleware('auth:api')->get('/user', function (Request $request) {
/*Route for the booking */
Route::get('/booking', 'BookingController@index');
-
Route::get('/booking/{book_id}', 'BookingController@show');
-
-Route::post('/booking', 'BookingController@store');
-
+Route::post('/booking/', 'BookingController@store');
Route::put('/booking/{book_id}', 'BookingController@update');
-
Route::delete('/booking/{book_id}', 'BookingController@delete');
diff --git a/tests/TestCase.php b/tests/TestCase.php
index 5a1e7091..17678639 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -3,6 +3,7 @@
namespace Tests;
use Illuminate\Foundation\Testing\RefreshDatabase;
+use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
diff --git a/tests/Unit/OrderTest.php b/tests/Unit/OrderTest.php
index 838dfc57..e80291b8 100644
--- a/tests/Unit/OrderTest.php
+++ b/tests/Unit/OrderTest.php
@@ -27,57 +27,62 @@ class OrderTest extends TestCase
// ]);
// }
- public function testGet()
- {
- $response = $this->get('/api/booking');
+ // public function testGet()
+ // {
+ // $response = $this->get('/api/booking');
- $response->assertStatus(200);
- }
+ // $response->assertStatus(200);
+ // }
public function testPost()
{
- $response = $this->json('POST', '/api/booking/1', [
-
- 'account_name' => 'kijd',
- 'account_num' => '1234',
- 'bank_name' => 'ferdas',
- 'bank_branch' => 'dersa',
- 'company_name' => 'desaq',
- 'company_address' => 'qada',
- 'bank_address' => 'daqa',
- 'swift_code' => '3eds2',
- 'cnap' => 'redah'
+ $response = $this->json('POST', '/api/booking/', [
+ 'account_name' => 'johnny',
+ 'account_num' => '1234567',
+ 'bank_name' => 'myabnak',
+ 'bank_branch' => 'banking',
+ 'company_name' => 'besaras',
+ 'company_address' => 'californina',
+ 'bank_address' => 'cyber',
+ 'swift_code' => '123wert',
+ 'cnap' => '2131rew',
+ 'term' => 'x1_cash',
+ 'amount' => '14000',
+ 'user_id' => '1',
+
]);
-
+ // dd($response->getContent());
$response
->assertStatus(201);
+
+ //dd($response->getContent());
}
- public function testPut()
- {
- $response = $this->json('PUT', '/api/booking/1', [
+ // public function testPut()
+ // {
+ // $response = $this->json('PUT', '/api/booking/1', [
- 'account_name' => 'kaokndfoanf',
- 'account_num' => '1234',
- 'bank_name' => 'ferdas',
- 'bank_branch' => 'dersa',
- 'company_name' => 'desaq',
- 'company_address' => 'qada',
- 'bank_address' => 'daqa',
- 'swift_code' => '3eds2',
- 'cnap' => 'redah'
+ // 'account_name' => 'kaokndfoanf',
+ // 'account_num' => '1234',
+ // 'bank_name' => 'ferdas',
+ // 'bank_branch' => 'dersa',
+ // 'company_name' => 'desaq',
+ // 'company_address' => 'qada',
+ // 'bank_address' => 'daqa',
+ // 'swift_code' => '3eds2',
+ // 'cnap' => 'redah'
- ]);
+ // ]);
- $response
- ->assertStatus(200);
- }
+ // $response
+ // ->assertStatus(200);
+ // }
- public function testDelete()
- {
- $response = $this->json('DELETE', '/api/booking/1');
+ // public function testDelete()
+ // {
+ // $response = $this->json('DELETE', '/api/booking/1');
- $response->assertStatus(204);
- }
+ // $response->assertStatus(204);
+ // }
}