Merge branch 'arief/booking' into 'master'

booking test merge request

See merge request CIEFWorldwideSdnBhd/exchange!4
This commit is contained in:
Jack Goh
2018-05-24 07:49:13 +00:00
33 changed files with 9131 additions and 206 deletions
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
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' ,'verification_status'];
public $timestamps = true;
public function user(){
return $this->belongsTo('app\User');
}
}
+194
View File
@@ -0,0 +1,194 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Booking;
use App\Rate;
use App\User;
use Auth;
class BookingController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
//public function index()
//{
// return response()->json(['success' => true, 'message'=> "You have successfully logged out."]);
//}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
//public function create()
//{
// return response()->json(['success' => true, 'message'=> "Success"]);
//}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$rates = Rate::all()->last();
$term = $request->input('term');
$rate = 1;
switch($term){
case "x1_cash":
$rate = $rates->x1_cash;
break;
case "x1_cheque":
$rate = $rates->x1_cheque;
break;
case "x1_ba":
$rate = $rates->x1_ba;
break;
case "x2_cash":
$rate = $rates->x2_cash;
break;
case "x2_cheque":
$rate = $rates->x2_cheque;
break;
case "x2_ba":
$rate = $rates->x2_ba;
break;
default:
//$rate = "no";
return Response::json(array(
'code' => 422,
'message' => 'Invalid input'
), 422);
break;
}
//Calculation part
// $bookings = Booking::all();
$amount = $request->input("amount");
if ($amount >= 10000 && ($term == 'x2_cash' || $term = 'x2_cheque' || $term = 'x2_ba')) {
$svcharge = 0;
}
else {
$svcharge = 20.00;
}
$bia = round(($amount + $svcharge) / $rate + (0*($amount + $svcharge)), 2);
//gst = 0.00% -> (0*($amount + $svcharge))
//bia = bank in amount in MYR
// return $bia;
$user = Auth::user();
$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->rmb_book_amount = $request->input('rmb_book_amount');
$booking->rmb_book_pay_method = $request->input('rmb_book_pay_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->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->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);
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
//public function show($id)
//{
// $booking = Booking::find($id);
// return view('booking.index');
//}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
//public function edit($id)
//{
//
//}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $book_id)
{
$book_id = Booking::find($book_id);
//$com_id->id = $request->input('id');
$book_id->account_name = $request->input('account_name');
$book_id->account_num = $request->input('account_num');
$book_id->bank_name = $request->input('bank_name');
$book_id->bank_branch = $request->input('bank_branch');
$book_id->company_name = $request->input('company_name');
$book_id->company_address = $request->input('company_address');
$book_id->bank_address = $request->input('bank_address');
$book_id->swift_code = $request->input('swift_code');
$book_id->cnap = $request->input('cnap');
$book_id->save();
return response()->json(['book_id'=>$book_id],200);
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function delete(Booking $book_id)
{
$book_id->delete($book_id);
return response()->json($book_id, 204);
}
}
+1
View File
@@ -6,6 +6,7 @@ use Laravel\Dusk\DuskServiceProvider;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
+5 -1
View File
@@ -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
View File
@@ -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",
+16 -1
View File
@@ -41,7 +41,7 @@ return [
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
@@ -54,6 +54,21 @@ return [
'engine' => null,
],
'testing' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => 'forunittest',
'username' => 'root',
'password' => '',
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),
@@ -0,0 +1,48 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateBookingsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('bookings', function (Blueprint $table) {
$table->increments('id');
$table->string('account_name');
$table->integer('account_num');
$table->string('bank_name');
$table->string('bank_branch');
$table->string('company_name');
$table->string('company_address');
$table->string('bank_address');
$table->string('swift_code');
$table->string('cnap');
$table->string('term');
$table->double('amount');
$table->unsignedInteger('rate_id');
$table->foreign('rate_id')
->references('id')->on('rates')
->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('bookings');
}
}
@@ -0,0 +1,34 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class ChangeUserIdInBookingsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('bookings', function (Blueprint $table) {
$table->unsignedInteger('user_id')->default('0');
$table->foreign('user_id')
->references('id')->on('users')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}
@@ -0,0 +1,32 @@
<?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')->default('0');
;
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
@@ -0,0 +1,50 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddBookingsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('bookings', function (Blueprint $table) {
$table->double('rmb_book_amount')->default('0');
$table->string('rmb_book_pay_method')->default(' ');
$table->string('rmb_book_account_name')->default(' ');
$table->string('rmb_book_bank_name')->default(' ');
$table->string('rmb_book_acc_no')->default(' ');
$table->string('rmb_book_bank_branch')->default(' ');
$table->double('usd_book_amount')->default('0');
$table->string('usd_book_pay_method')->default(' ');
$table->string('usd_book_company_name')->default(' ');
$table->string('usd_book_company_address')->default(' ');
$table->string('usd_book_swift_code')->default(' ');
$table->string('usd_book_cnap')->default(' ');
$table->string('usd_book_bank_branch')->default(' ');
$table->boolean('verification_status')->default('1'); // Results in a default value of 1.
// $table->foreign('status_id')
// ->references('id')->on('status')
// ->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('bookings', function (Blueprint $table) {
//
});
}
}
+38
View File
@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Seeder;
use Carbon\Carbon;
use App\User;
use App\Rate;
class BookTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$user = User::where("email", "user@example.com")->first();
$rate = Rate::all()->last();
DB::table('bookings')->insert([
'account_name' => 'milah',
'account_num' => '99898',
'bank_name' => 'maybank',
'bank_branch' => 'rembau',
'company_name' => 'ICEF',
'company_address' => 'selangor',
'bank_address' => 'cyber',
'swift_code' => 'qwe123',
'cnap' => '123asd',
'term' => 'x1',
'amount' => 1.2,
'rate_id' => $rate->id,
'user_id' => $user->id,
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
]);
}
}
+3 -3
View File
@@ -13,8 +13,8 @@ class DatabaseSeeder extends Seeder
{
$this->call(UsersTableSeeder::class);
$this->call(RolesAndPermissionsSeeder::class);
$this->call(UserRoleTableSeeder::class);
$this->call(UserRoleSeeder::class);
$this->call(RateTableSeeder::class);
$this->call(BookTableSeeder::class);
}
}
+37
View File
@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Seeder;
use Carbon\Carbon;
class RateTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('rates')->insert([
'x1_cash' => 1.2,
'x1_cheque' => 1.2,
'x1_ba' => 1.2,
'x2_cash' => 1.2,
'x2_cheque' => 1.2,
'x2_ba' => 1.2,
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
]);
DB::table('rates')->insert([
'x1_cash' => 1.3,
'x1_cheque' => 1.3,
'x1_ba' => 1.3,
'x2_cash' => 1.3,
'x2_cheque' => 1.3,
'x2_ba' => 1.3,
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
]);
}
}
@@ -4,7 +4,7 @@ use Illuminate\Database\Seeder;
use App\User;
use App\Role;
class UserRoleTableSeeder extends Seeder
class UserRoleSeeder extends Seeder
{
/**
* Run the database seeds.
+78 -39
View File
@@ -1,39 +1,78 @@
APP_NAME=exchange
APP_ENV=local
APP_KEY=base64:Fu2YulXExzm9HJ5LgVmZUmcbRkchHkc82q02MorN5GQ=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secr
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
APP_NAME=IZYIM
APP_ENV=local
APP_KEY=base64:Fu2YulXExzm9HJ5LgVmZUmcbRkchHkc82q02MorN5GQ=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=default
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
APP_NAME=exchange
APP_ENV=local
APP_KEY=base64:Fu2YulXExzm9HJ5LgVmZUmcbRkchHkc82q02MorN5GQ=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secr
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
View File
+1
View File
@@ -18,6 +18,7 @@
"@fortawesome/vue-fontawesome": "^0.0.22",
"axios": "^0.18.0",
"bootstrap": "^4.0.0",
"element-ui": "^2.3.9",
"jquery": "^3.3.1",
"js-cookie": "^2.2.0",
"popper.js": "^1.14.1",
+2
View File
@@ -27,6 +27,8 @@
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="DB_CONNECTION" value="testing"/>
<env name="MAIL_DRIVER" value="array"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
</php>
Binary file not shown.
Binary file not shown.
+3 -3
View File
@@ -1,7 +1,7 @@
{
"/js/lang-zh-CN.05f1eac96ac4b1a58972.js": "/js/lang-zh-CN.05f1eac96ac4b1a58972.js",
"/js/lang-es.7f2b93b9c03c518567a9.js": "/js/lang-es.7f2b93b9c03c518567a9.js",
"/js/lang-en.592895da306250f00312.js": "/js/lang-en.592895da306250f00312.js",
"/js/lang-zh-CN.c0da3973e52421a8cfe5.js": "/js/lang-zh-CN.c0da3973e52421a8cfe5.js",
"/js/lang-es.f4a1a5b4a30e92527b46.js": "/js/lang-es.f4a1a5b4a30e92527b46.js",
"/js/lang-en.0f790217417404ecc662.js": "/js/lang-en.0f790217417404ecc662.js",
"/js/app.js": "/js/app.js",
"/css/app.css": "/css/app.css"
}
+5
View File
@@ -3,16 +3,21 @@ import store from '~/store'
import router from '~/router'
import i18n from '~/plugins/i18n'
import App from '~/components/App'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import locale from 'element-ui/lib/locale/lang/en'
import '~/plugins'
import '~/components'
Vue.config.productionTip = false
Vue.use(ElementUI, { locale })
/* eslint-disable no-new */
new Vue({
i18n,
store,
router,
el: '#app',
...App
})
+113 -9
View File
@@ -1,15 +1,119 @@
<template>
<card :title="$t('home')">
{{ $t('you_are_logged_in') }}
</card>
<el-main>
<div class="row">
<div class="col-lg-2 m-auto col-centered">
<el-input placeholder="Amount" v-model="input"></el-input>
</div>
<div class="col-lg-8 m-auto col-centered">
<el-select v-model="value" placeholder="MYR">
<el-option v-for="item in options1" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
<el-button icon="el-icon-search" circle></el-button>
<el-select v-model="value2" placeholder="RMB">
<el-option v-for="item2 in options2" :key="item2.value2" :label="item2.label2" :value="item2.value2">
</el-option>
</el-select>
</div>
</div>
<hr>
<el-row :gutter="20">
<el-table :data="tableData" style="width: 100%">
<el-table-column prop="date" label="Date" sortable :filters="[{text: '2016-05-01', value: '2016-05-01'}, {text: '2016-05-02', value: '2016-05-02'}, {text: '2016-05-03', value: '2016-05-03'}, {text: '2016-05-04', value: '2016-05-04'}]"
:filter-method="filterHandler">
</el-table-column>
<el-table-column prop="name" label="Order" >
</el-table-column>
<el-table-column prop="address" label="Term" :formatter="formatter">
</el-table-column>
<el-table-column prop="address" label="Rate" :formatter="formatter">
</el-table-column>
<el-table-column prop="address" label="Amount" :formatter="formatter">
</el-table-column>
<el-table-column prop="address" label="Transfer Amount" :formatter="formatter">
</el-table-column>
<el-table-column prop="address" label="ETA" :formatter="formatter">
</el-table-column>
<el-table-column prop="address" label="Pay Method" :formatter="formatter">
</el-table-column>
<el-table-column prop="address" label="Status" :formatter="formatter">
</el-table-column>
<el-table-column prop="address" label="Balance" :formatter="formatter">
</el-table-column>
<el-table-column prop="address" label="Time Left" :formatter="formatter">
</el-table-column>
<el-table-column prop="tag" label="Tag" width="100" :filters="[{ text: 'Home', value: 'Home' }, { text: 'Office', value: 'Office' }]"
:filter-method="filterTag" filter-placement="bottom-end">
<template slot-scope="scope">
<el-tag :type="scope.row.tag === 'Home' ? 'primary' : 'success'" disable-transitions>{{scope.row.tag}}</el-tag>
</template>
</el-table-column>
</el-table>
</el-row>
</el-main>
</template>
<script>
export default {
middleware: ['auth'],
export default {
middleware: ['auth'],
metaInfo () {
return { title: this.$t('home') }
data() {
return {
options1: [{
value: 'RMB',
label: 'RMB'
}, {
value: 'MYR',
label: 'MYR'
}],
options2: [{
value2: 'MYR',
label2: 'MYR'
}, {
value2: 'RMB',
label2: 'RMB'
}],
tableData: [{
date: '2016-05-03',
name: 'Tom',
address: 'No. 189, Grove St, Los Angeles',
tag: 'Home'
}, {
date: '2016-05-02',
name: 'Tom',
address: 'No. 189, Grove St, Los Angeles',
tag: 'Office'
}, {
date: '2016-05-04',
name: 'Tom',
address: 'No. 189, Grove St, Los Angeles',
tag: 'Home'
}, {
date: '2016-05-01',
name: 'Tom',
address: 'No. 189, Grove St, Los Angeles',
tag: 'Office'
}],
value: '',
value2: '',
input: '',
}
},
methods: {
formatter(row, column) {
return row.address;
},
filterTag(value, row) {
return row.tag === value;
},
filterHandler(value, row, column) {
const property = column['property'];
return row[property] === value;
}
}
}
}
</script>
</script>
+95
View File
@@ -0,0 +1,95 @@
<!doctype html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
<!-- Styles -->
<style>
html, body {
background-color: #fff;
color: #636b6f;
font-family: 'Raleway', sans-serif;
font-weight: 100;
height: 100vh;
margin: 0;
}
.full-height {
height: 100vh;
}
.flex-center {
align-items: center;
display: flex;
justify-content: center;
}
.position-ref {
position: relative;
}
.top-right {
position: absolute;
right: 10px;
top: 18px;
}
.content {
text-align: center;
}
.title {
font-size: 84px;
}
.links > a {
color: #636b6f;
padding: 0 25px;
font-size: 12px;
font-weight: 600;
letter-spacing: .1rem;
text-decoration: none;
text-transform: uppercase;
}
.m-b-md {
margin-bottom: 30px;
}
</style>
</head>
<body>
<div class="flex-center position-ref full-height">
@if (Route::has('login'))
<div class="top-right links">
@auth
<a href="{{ url('/home') }}">Home</a>
@else
<a href="{{ route('login') }}">Login</a>
<a href="{{ route('register') }}">Register</a>
@endauth
</div>
@endif
<div class="content">
<div class="title m-b-md">
Laravelllll
</div>
<div class="links">
<a href="https://laravel.com/docs">Documentation</a>
<a href="https://laracasts.com">Laracasts</a>
<a href="https://laravel-news.com">News</a>
<a href="https://forge.laravel.com">Forge</a>
<a href="https://github.com/laravel/laravel">GitHub</a>
</div>
</div>
</div>
</body>
</html>
+2
View File
@@ -27,6 +27,7 @@ $polyfills = [
<title>{{ config('app.name') }}</title>
<link rel="stylesheet" href="{{ mix('css/app.css') }}">
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>
<body>
<div id="app"></div>
@@ -44,6 +45,7 @@ $polyfills = [
<script src="{{ mix('js/manifest.js') }}"></script>
<script src="{{ mix('js/vendor.js') }}"></script>
<script src="{{ mix('js/app.js') }}"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
@endif
</body>
</html>
+18 -2
View File
@@ -17,16 +17,32 @@ Use App\SettingSupplier;
|
*/
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
/*Route for the booking */
Route::get('/booking', 'BookingController@index');
Route::get('/booking/{book_id}', 'BookingController@show');
Route::post('/booking/', 'BookingController@store');
Route::put('/booking/{book_id}', 'BookingController@update');
Route::delete('/booking/{book_id}', 'BookingController@delete');
//Route::middleware('auth:api')->get('/user', function (Request $request) {
// return $request->user();
//});
Route::group(['middleware' => 'auth:api'], function () {
Route::post('logout', 'Auth\LoginController@logout');
Route::get('/user', function (Request $request) {
return $request->user();
});
});
Route::patch('settings/profile', 'Settings\ProfileController@update');
Route::patch('settings/password', 'Settings\PasswordController@update');
});
Route::group(['middleware' => 'guest:api'], function () {
Route::post('login', 'Auth\LoginController@login');
@@ -63,4 +79,4 @@ Route::post('setting-supplier', 'SettingSupplierController@store');
Route::put('setting-supplier/{supplier}', 'SettingSupplierController@update');
Route::delete('setting-supplier/{supplier}', 'SettingSupplierController@delete');
Route::post('upload-china-bankslip', 'ChinaBankSlipController@store');
Route::post('upload-china-bankslip', 'ChinaBankSlipController@store');
+19
View File
@@ -11,6 +11,25 @@
|
*/
Route::get('/', function () {
return view('welcome');
});
/*Route for the booking */
// Route::get('/booking', 'BookingController@index');
// Route::get('/booking/{booking}', 'BookingController@show');
// Route::post('/booking', 'BookingController@create');
// Route::post('/booking', 'BookingController@store');
// Route::put('/booking/{user-id}', 'BookingController@update');
// Route::delete('/booking/{user-id}', 'BookingController@delete');
Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.request');
Route::post('password/reset', 'Auth\ResetPasswordController@postReset')->name('password.reset');
Route::get('{path}', function () {
return view('index');
})->where('path', '(.*)');
+3 -1
View File
@@ -1,10 +1,12 @@
<?php
/**
* Laravel - A PHP Framework For Web Artisans.
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
-129
View File
@@ -1,129 +0,0 @@
<?php
namespace Tests\Feature;
use App\User;
use Mockery as m;
use Tests\TestCase;
use Laravel\Socialite\Facades\Socialite;
use PHPUnit\Framework\Assert as PHPUnit;
use Illuminate\Foundation\Testing\TestResponse;
use Laravel\Socialite\Two\User as SocialiteUser;
class OAuthTest extends TestCase
{
public function setUp()
{
parent::setUp();
TestResponse::macro('assertText', function ($text) {
PHPUnit::assertTrue(str_contains($this->getContent(), $text), "Expected text [{$text}] not found.");
return $this;
});
TestResponse::macro('assertTextMissing', function ($text) {
PHPUnit::assertFalse(str_contains($this->getContent(), $text), "Expected missing text [{$text}] found.");
return $this;
});
}
/** @test */
public function redirect_to_provider()
{
$this->mockSocialite('github');
$this->postJson('/api/oauth/github')
->assertSuccessful()
->assertJson(['url' => 'https://url-to-provider']);
}
/** @test */
public function create_user_and_return_token()
{
$this->mockSocialite('github', [
'id' => '123',
'name' => 'Test User',
'email' => 'test@example.com',
'token' => 'access-token',
'refreshToken' => 'refresh-token',
]);
$this->withoutExceptionHandling();
$this->get('/api/oauth/github/callback')
->assertText('token')
->assertSuccessful();
$this->assertDatabaseHas('users', [
'name' => 'Test User',
'email' => 'test@example.com',
]);
$this->assertDatabaseHas('oauth_providers', [
'user_id' => User::first()->id,
'provider' => 'github',
'provider_user_id' => '123',
'access_token' => 'access-token',
'refresh_token' => 'refresh-token',
]);
}
/** @test */
public function update_user_and_return_token()
{
$user = factory(User::class)->create(['email' => 'test@example.com']);
$user->oauthProviders()->create([
'provider' => 'github',
'provider_user_id' => '123',
]);
$this->mockSocialite('github', [
'id' => '123',
'email' => 'test@example.com',
'token' => 'updated-access-token',
'refreshToken' => 'updated-refresh-token',
]);
$this->get('/api/oauth/github/callback')
->assertText('token')
->assertSuccessful();
$this->assertDatabaseHas('oauth_providers', [
'user_id' => $user->id,
'access_token' => 'updated-access-token',
'refresh_token' => 'updated-refresh-token',
]);
}
/** @test */
public function can_not_create_user_if_email_is_taken()
{
factory(User::class)->create(['email' => 'test@example.com']);
$this->mockSocialite('github', ['email' => 'test@example.com']);
$this->get('/api/oauth/github/callback')
->assertText('Email already taken.')
->assertTextMissing('token')
->assertStatus(400);
}
protected function mockSocialite($provider, $user = null)
{
$mock = Socialite::shouldReceive('stateless')
->andReturn(m::self())
->shouldReceive('driver')
->with($provider)
->andReturn(m::self());
if ($user) {
$mock->shouldReceive('user')
->andReturn((new SocialiteUser)->setRaw($user)->map($user));
} else {
$mock->shouldReceive('redirect')
->andReturn(redirect('https://url-to-provider'));
}
}
}
+1
View File
@@ -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
View File
@@ -0,0 +1,43 @@
<?php
namespace Tests\Unit\BookingTest;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Database\Seeder;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Artisan;
use App\User;
class BookingTest extends TestCase
{
protected $user;
public function setUp()
{
parent::setUp();
Artisan::call('db:seed');
$this->user = factory(User::class)->create();
}
public function testPost()
{
$response =
$this->actingAs($this->user)
->postJson('/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' => 'x2_cash',
'amount' => '14000'
]);
$response->assertStatus(500);
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff