mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 04:14:04 +00:00
added booking seeder
updated booking controller added test for booking
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Generated
+22
-17
@@ -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",
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddBiaInBookingsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('bookings', function (Blueprint $table) {
|
||||
$table->double('bia');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -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'),
|
||||
]);
|
||||
|
||||
@@ -27,12 +27,9 @@
|
||||
<env name="CACHE_DRIVER" value="array"/>
|
||||
<env name="SESSION_DRIVER" value="array"/>
|
||||
<env name="QUEUE_DRIVER" value="sync"/>
|
||||
<<<<<<< HEAD
|
||||
<env name="DB_CONNECTION" value="testing"/>
|
||||
<env name="MAIL_DRIVER" value="array"/>
|
||||
=======
|
||||
<env name="DB_CONNECTION" value="sqlite"/>
|
||||
<env name="DB_DATABASE" value=":memory:"/>
|
||||
>>>>>>> 06aa931eb57dbc7c95748ade6e3bb659f0659abe
|
||||
</php>
|
||||
</phpunit>
|
||||
|
||||
+1
-5
@@ -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');
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
+43
-38
@@ -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);
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user