mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 12:24:09 +00:00
Merge branch 'fix/marking' into 'master'
Fix/marking See merge request CIEFWorldwideSdnBhd/exchange!64
This commit is contained in:
+3
-2
@@ -7,7 +7,8 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class Booking extends Model
|
||||
{
|
||||
// protected $guarded = [];
|
||||
protected $hidden = array('user_id',
|
||||
protected $hidden = array( "user",
|
||||
"user_id",
|
||||
"rate_id",
|
||||
"rmb_book_amount",
|
||||
"rmb_book_pay_method",
|
||||
@@ -29,7 +30,7 @@ class Booking extends Model
|
||||
public $timestamps = true;
|
||||
|
||||
public function user(){
|
||||
return $this->belongsTo('app\User');
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function supplierBooking(){
|
||||
|
||||
@@ -78,6 +78,7 @@ class RegisterController extends Controller
|
||||
$user = new User();
|
||||
$user->name = $data['name'];
|
||||
$user->email = $data['email'];
|
||||
$user->marking = $marking->marking;
|
||||
$user->password = bcrypt($data['password']);
|
||||
|
||||
$user->save();
|
||||
|
||||
@@ -20,12 +20,11 @@ class BookingController extends Controller
|
||||
|
||||
public function index(){
|
||||
$user = Auth::user();
|
||||
$bookings = Booking::select('id', 'created_at', 'status', 'rate', 'term', 'amount', 'bia', 'verification_status')
|
||||
$bookings = Booking::select('user_id', 'id', 'created_at', 'status', 'rate', 'term', 'amount', 'bia', 'verification_status')
|
||||
->where('user_id', $user->id)
|
||||
->orderby('updated_at','desc')
|
||||
->paginate(10);
|
||||
|
||||
|
||||
// reformat to fit frontend structure
|
||||
foreach ($bookings as $booking) {
|
||||
// set timeout
|
||||
@@ -42,7 +41,7 @@ class BookingController extends Controller
|
||||
|
||||
// TODO : transfer_amount change name to bia
|
||||
$booking->transfer_amount = $booking->bia;
|
||||
|
||||
|
||||
$booking->track_status = "(". $booking->status ."/7)";
|
||||
switch ($booking->status) {
|
||||
case 1:
|
||||
@@ -69,15 +68,15 @@ class BookingController extends Controller
|
||||
default:
|
||||
$status_desc = "";
|
||||
}
|
||||
$booking->status_desc = $status_desc;
|
||||
$booking->marking = $booking->user->marking;
|
||||
}
|
||||
|
||||
|
||||
return $bookings;
|
||||
}
|
||||
|
||||
public function adminIndex(){
|
||||
$user = Auth::user();
|
||||
$bookings = Booking::select('id', 'created_at', 'admin_status', 'rate', 'term', 'amount', 'bia', 'verification_status')
|
||||
$bookings = Booking::select('user_id', 'id', 'created_at', 'admin_status', 'rate', 'term', 'amount', 'bia', 'verification_status')
|
||||
->orderby('updated_at','desc')
|
||||
->get();
|
||||
|
||||
@@ -126,7 +125,8 @@ class BookingController extends Controller
|
||||
break;
|
||||
default:
|
||||
$status_desc = "";
|
||||
}
|
||||
}
|
||||
$booking->marking = $booking->user->marking;
|
||||
$booking->status_desc = $status_desc;
|
||||
}
|
||||
return $bookings;
|
||||
@@ -169,6 +169,7 @@ class BookingController extends Controller
|
||||
$time_in_seconds = SettingCredit::orderby('updated_at','desc')->first()->time_limit;
|
||||
$difference_in_seconds = ($date1->format('U') + $time_in_seconds) - ($date2->format('U'));
|
||||
$booking->timeout = $difference_in_seconds;
|
||||
$booking->marking = $booking->user->marking;
|
||||
|
||||
if (!$booking){
|
||||
return response()->json(['success'=>false, 'message'=>'not found'], 404);
|
||||
@@ -214,6 +215,7 @@ class BookingController extends Controller
|
||||
$time_in_seconds = SettingCredit::orderby('updated_at','desc')->first()->time_limit;
|
||||
$difference_in_seconds = ($date1->format('U') + $time_in_seconds) - ($date2->format('U'));
|
||||
$booking->timeout = $difference_in_seconds;
|
||||
$booking->marking = $booking->user->marking;
|
||||
|
||||
if (!$booking){
|
||||
return response()->json(['success'=>false, 'message'=>'not found'], 404);
|
||||
@@ -524,6 +526,7 @@ class BookingController extends Controller
|
||||
$term = $request->input('term');
|
||||
$china_beneficiary = $request->input('china_beneficiary');
|
||||
$rates = Rate::orderby('updated_at','desc')->first();
|
||||
$marking = $user = Auth::user()->marking;
|
||||
|
||||
$creditLimit = SettingCredit::orderby('updated_at','desc')->first();
|
||||
|
||||
@@ -534,9 +537,7 @@ class BookingController extends Controller
|
||||
if($amount > $creditLimit->rmb_credit_limit){
|
||||
return response()->json(["message" => "Exceed credit limit, please contact our sales team for larger quantitiy"], 400);
|
||||
}
|
||||
|
||||
// TODO : get marking
|
||||
$marking = "123X";
|
||||
|
||||
|
||||
switch ($term) {
|
||||
case "x1_cash":
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ class User extends Authenticatable implements JWTSubject
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
'password', 'remember_token'
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -98,7 +98,7 @@ class User extends Authenticatable implements JWTSubject
|
||||
return [];
|
||||
}
|
||||
|
||||
public function booking(){
|
||||
public function bookings(){
|
||||
return $this->hasMany(Booking::class);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,5 +21,6 @@ $factory->define(App\User::class, function (Faker $faker) {
|
||||
'email' => $faker->unique()->safeEmail,
|
||||
'password' => $password ?: $password = bcrypt('secret'),
|
||||
'remember_token' => str_random(10),
|
||||
'marking' => $faker->name,
|
||||
];
|
||||
});
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddMarkingToUserTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function($table)
|
||||
{
|
||||
$table->string('marking');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ class BookTableSeeder extends Seeder
|
||||
'rate_id' => $rate->id,
|
||||
'user_id' => $user->id,
|
||||
'status' => 2,
|
||||
'admin_status' => 1,
|
||||
'admin_status' => 2,
|
||||
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
||||
'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
@@ -11,6 +11,7 @@ class MarkingSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('markings')->truncate();
|
||||
DB::table('markings')->insert([
|
||||
'marking' => 'hehe',
|
||||
'email' => 'hehe@gmail.com'
|
||||
|
||||
@@ -11,6 +11,7 @@ class SettingMalaysiaBankSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('setting_malaysia_banks')->truncate();
|
||||
DB::table('setting_malaysia_banks')->insert([
|
||||
'company_name' => 'CIEF',
|
||||
'bank_name' => 'Maybank',
|
||||
|
||||
@@ -16,8 +16,8 @@ class UsersTableSeeder extends Seeder
|
||||
DB::table('users')->delete();
|
||||
|
||||
$users = array(
|
||||
['name' => 'User', 'email' => 'user@example.com', 'password' => Hash::make('secret')],
|
||||
['name' => 'Admin', 'email' => 'admin@example.com', 'password' => Hash::make('secret')],
|
||||
['name' => 'User', 'marking'=> 'X9', 'email' => 'user@example.com', 'password' => Hash::make('secret')],
|
||||
['name' => 'Admin', 'marking'=> 'X10', 'email' => 'admin@example.com', 'password' => Hash::make('secret')],
|
||||
);
|
||||
|
||||
foreach ($users as $user)
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false">
|
||||
stopOnFailure="true">
|
||||
<testsuites>
|
||||
<testsuite name="Feature">
|
||||
<directory suffix="Test.php">./tests/Feature</directory>
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
<div class="cell">Customer Marking :</div>
|
||||
</td>
|
||||
<td class="el-table_2_column_10 is-left ">
|
||||
<div class="cell">CIEF/150ECE</div>
|
||||
<div class="cell">{{ booking_details.marking }}</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="el-table__row">
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<div class="cell">Customer Marking :</div>
|
||||
</td>
|
||||
<td class="el-table_2_column_10 is-left ">
|
||||
<div class="cell">CIEF/150ECE</div>
|
||||
<div class="cell">{{ booking_details.marking }}</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="el-table__row">
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<div class="cell">Customer Marking :</div>
|
||||
</td>
|
||||
<td class="el-table_2_column_10 is-left ">
|
||||
<div class="cell">CIEF/150ECE</div>
|
||||
<div class="cell">{{ booking_details.marking }}</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="el-table__row">
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<div class="cell">Customer Marking :</div>
|
||||
</td>
|
||||
<td class="el-table_2_column_10 is-left ">
|
||||
<div class="cell">CIEF/150ECE</div>
|
||||
<div class="cell">{{ booking_details.marking }}</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="el-table__row">
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
<div class="cell">Customer Marking :</div>
|
||||
</td>
|
||||
<td class="el-table_2_column_10 is-left ">
|
||||
<div class="cell">CIEF/150ECE</div>
|
||||
<div class="cell">{{ booking_details.marking }}</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="el-table__row">
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<div class="cell">Customer Marking :</div>
|
||||
</td>
|
||||
<td class="el-table_2_column_10 is-left ">
|
||||
<div class="cell">CIEF/150ECE</div>
|
||||
<div class="cell">{{ booking_details.marking }}</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="el-table__row">
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
<el-button slot-scope="scope" type="text" @click="(event) => { BookingStatus(scope.row.admin_status, scope.row.id) }"> {{ scope.row.id }}</el-button>
|
||||
</el-table-column>
|
||||
<el-table-column label="DateTime" prop="created_at" width="180" sortable/>
|
||||
<el-table-column :filters="[{text: 'X1', value: 'X1'}, {text: 'X2', value: 'X2'}]" :filter-method="filterHandler" label="Term" prop="term" width="100"/> -->
|
||||
<el-table-column label="Marking" width="120" prop="marking" />
|
||||
<el-table-column :filters="[{text: 'X1', value: 'X1'}, {text: 'X2', value: 'X2'}]" :filter-method="filterHandler" label="Term" prop="term" width="100"/>
|
||||
<el-table-column label="Rate" width="74" prop="rate" />
|
||||
<el-table-column label="Amount" prop="amount" justify="center" width="110" />
|
||||
<el-table-column :filters="[{text: 'RMB', value: 'RMB'}, {text: 'USD', value: 'USD'}]" :filter-method="filterHandler" label="Transfer Amount"
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
<div class="cell">Customer Marking :</div>
|
||||
</td>
|
||||
<td class="el-table_2_column_10 is-left ">
|
||||
<div class="cell">CIEF/150ECE</div>
|
||||
<div class="cell">{{ booking_details.marking }}</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="el-table__row">
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
<div class="cell">Customer Marking :</div>
|
||||
</td>
|
||||
<td class="el-table_2_column_10 is-left ">
|
||||
<div class="cell">CIEF/150ECE</div>
|
||||
<div class="cell">{{ booking_details.marking }}</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="el-table__row">
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
<div class="cell">Customer Marking :</div>
|
||||
</td>
|
||||
<td class="el-table_2_column_10 is-left ">
|
||||
<div class="cell">CIEF/150ECE</div>
|
||||
<div class="cell">{{ booking_details.marking }}</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="el-table__row">
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
<div class="cell">Customer Marking :</div>
|
||||
</td>
|
||||
<td class="el-table_2_column_10 is-left ">
|
||||
<div class="cell">CIEF/150ECE</div>
|
||||
<div class="cell">{{ booking_details.marking }}</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="el-table__row">
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
<div class="cell">Customer Marking :</div>
|
||||
</td>
|
||||
<td class="el-table_2_column_10 is-left ">
|
||||
<div class="cell">CIEF/150ECE</div>
|
||||
<div class="cell">{{ booking_details.marking }}</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="el-table__row">
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
<div class="cell">Customer Marking :</div>
|
||||
</td>
|
||||
<td class="el-table_2_column_10 is-left ">
|
||||
<div class="cell">CIEF/150ECE</div>
|
||||
<div class="cell">{{ booking_details.marking }}</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="el-table__row">
|
||||
|
||||
@@ -13,8 +13,8 @@ class LoginTest extends TestCase
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->user = factory(User::class)->create();
|
||||
$this->withoutExceptionHandling();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
@@ -35,7 +35,7 @@ class LoginTest extends TestCase
|
||||
$this->actingAs($this->user)
|
||||
->getJson('/api/user')
|
||||
->assertSuccessful()
|
||||
->assertJsonStructure(['id', 'name', 'email']);
|
||||
->assertJsonStructure(['id', 'name', 'email', 'marking']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
|
||||
Reference in New Issue
Block a user