mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 04:14:04 +00:00
updated user has many booking to bookings
added index booking with user marking added turncate marking when seeding added turncate settingmalaysiabank when seeding added marking to user seeder
This commit is contained in:
+2
-2
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class Booking extends Model
|
||||
{
|
||||
// protected $guarded = [];
|
||||
protected $hidden = array('user_id',
|
||||
protected $hidden = array("user_id",
|
||||
"rate_id",
|
||||
"rmb_book_amount",
|
||||
"rmb_book_pay_method",
|
||||
@@ -29,7 +29,7 @@ class Booking extends Model
|
||||
public $timestamps = true;
|
||||
|
||||
public function user(){
|
||||
return $this->belongsTo('app\User');
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function supplierBooking(){
|
||||
|
||||
@@ -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,9 +68,9 @@ class BookingController extends Controller
|
||||
default:
|
||||
$status_desc = "";
|
||||
}
|
||||
$booking->status_desc = $status_desc;
|
||||
$booking->marking = $booking->user->marking;
|
||||
}
|
||||
|
||||
|
||||
return $bookings;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ class User extends Authenticatable implements JWTSubject
|
||||
return [];
|
||||
}
|
||||
|
||||
public function booking(){
|
||||
public function bookings(){
|
||||
return $this->hasMany(Booking::class);
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user