mirror of
https://gitlab.com/omair-personal/exchange.git
synced 2026-08-19 04:24:08 +00:00
fixBankInSlip
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Booking extends Model
|
||||
{
|
||||
// protected $guarded = [];
|
||||
protected $hidden = array( "user",
|
||||
"user_id",
|
||||
"rate_id",
|
||||
"rmb_book_amount",
|
||||
"rmb_book_pay_method",
|
||||
"rmb_book_account_name",
|
||||
"rmb_book_bank_name",
|
||||
"rmb_book_acc_no",
|
||||
"rmb_book_bank_branch",
|
||||
"usd_book_amount",
|
||||
"usd_book_pay_method",
|
||||
"usd_book_company_name",
|
||||
"usd_book_company_address",
|
||||
"usd_book_swift_code",
|
||||
"usd_book_cnap",
|
||||
"usd_book_bank_branch");
|
||||
|
||||
protected $fillable = ['term', 'rate_id', 'user_id', 'amount', 'account_name', 'account_num', 'bank_name',
|
||||
'bank_branch', 'company_name'];
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
public function user(){
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function supplierBooking(){
|
||||
return $this->hasOne(SupplierBooking::class);
|
||||
}
|
||||
|
||||
public function chinaBankSlip(){
|
||||
return $this->hasMany(ChinaBankSlip::class);
|
||||
}
|
||||
|
||||
public function userBankSlip(){
|
||||
return $this->hasOne(UserBankSlip::class);
|
||||
}
|
||||
|
||||
public function purchaseOrder(){
|
||||
return $this->hasOne(PurchaseOrder::class);
|
||||
}
|
||||
|
||||
public function invoice(){
|
||||
return $this->hasOne(Invoice::class);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ChinaBankSlip extends Model
|
||||
{
|
||||
protected $fillable = ['actual_transfer_amount','date','details','china_bank_slip_path'];
|
||||
|
||||
public function booking()
|
||||
{
|
||||
return $this->belongsTo(Booking::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
// $schedule->command('inspire')
|
||||
// ->hourly();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use App\Rate;
|
||||
|
||||
class RateUpdated implements ShouldBroadcast
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public $rate;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Rate $rate)
|
||||
{
|
||||
$this->rate = $rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new Channel('rate-updated');
|
||||
//return new PrivateChannel('rate-updated');
|
||||
}
|
||||
|
||||
public function broadcastWith() {
|
||||
return [
|
||||
'rate' => $this->rate,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class EmailTakenException extends Exception
|
||||
{
|
||||
/**
|
||||
* Render the exception as an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request)
|
||||
{
|
||||
return response()->view('oauth.emailTaken', [], 400);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed for validation exceptions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||
*
|
||||
* @param \Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $exception)
|
||||
{
|
||||
parent::report($exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $exception
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $exception)
|
||||
{
|
||||
// This will replace our 404 response with
|
||||
// a JSON response.
|
||||
if ($exception instanceof ModelNotFoundException) {
|
||||
return response()->json([
|
||||
'error' => 'Resource not found'
|
||||
], 404);
|
||||
}
|
||||
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
use SendsPasswordResetEmails;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the response for a successful password reset link.
|
||||
*
|
||||
* @param string $response
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
protected function sendResetLink(Request $request)
|
||||
{
|
||||
if($request->input('email')) {
|
||||
$this->sendResetLinkEmail($request);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'error' => false,
|
||||
'status' => 'We have sent reset password link to '. $request->input('email')
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the response for a failed password reset link.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string $response
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
protected function sendResetLinkFailedResponse(Request $request, $response)
|
||||
{
|
||||
return response()->json(['email' => trans($response)], 400);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to log the user into the application.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return bool
|
||||
*/
|
||||
protected function attemptLogin(Request $request)
|
||||
{
|
||||
$token = $this->guard()->attempt($this->credentials($request));
|
||||
|
||||
if ($token) {
|
||||
$this->guard()->setToken($token);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the response after the user was authenticated.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
protected function sendLoginResponse(Request $request)
|
||||
{
|
||||
$this->clearLoginAttempts($request);
|
||||
|
||||
$token = (string) $this->guard()->getToken();
|
||||
$expiration = $this->guard()->getPayload()->get('exp');
|
||||
|
||||
return [
|
||||
'token' => $token,
|
||||
'token_type' => 'bearer',
|
||||
'expires_in' => $expiration - time(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the user out of the application.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function logout(Request $request)
|
||||
{
|
||||
$this->guard()->logout();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\User;
|
||||
use App\OAuthProvider;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Exceptions\EmailTakenException;
|
||||
use Laravel\Socialite\Facades\Socialite;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Tymon\JWTAuth\Facades\JWTAuth;
|
||||
use Tymon\JWTAuth\Exceptions\JWTException;
|
||||
|
||||
class OAuthController extends Controller
|
||||
{
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
config([
|
||||
'services.github.redirect' => route('oauth.callback', 'github'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect the user to the provider authentication page.
|
||||
*
|
||||
* @param string $provider
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function redirectToProvider($provider)
|
||||
{
|
||||
return [
|
||||
'url' => Socialite::driver($provider)->stateless()->redirect()->getTargetUrl(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain the user information from the provider.
|
||||
*
|
||||
* @param string $driver
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function handleProviderCallback($provider)
|
||||
{
|
||||
$user = Socialite::driver($provider)->stateless()->user();
|
||||
$user = $this->findOrCreateUser($provider, $user);
|
||||
|
||||
$this->guard()->setToken(
|
||||
$token = $this->guard()->login($user)
|
||||
);
|
||||
|
||||
return view('oauth/callback', [
|
||||
'token' => $token,
|
||||
'token_type' => 'bearer',
|
||||
'expires_in' => $this->guard()->getPayload()->get('exp') - time(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $provider
|
||||
* @param \Laravel\Socialite\Contracts\User $sUser
|
||||
* @return \App\User|false
|
||||
*/
|
||||
protected function findOrCreateUser($provider, $user)
|
||||
{
|
||||
$oauthProvider = OAuthProvider::where('provider', $provider)
|
||||
->where('provider_user_id', $user->getId())
|
||||
->first();
|
||||
|
||||
if ($oauthProvider) {
|
||||
$oauthProvider->update([
|
||||
'access_token' => $user->token,
|
||||
'refresh_token' => $user->refreshToken,
|
||||
]);
|
||||
|
||||
return $oauthProvider->user;
|
||||
}
|
||||
|
||||
if (User::where('email', $user->getEmail())->exists()) {
|
||||
throw new EmailTakenException;
|
||||
}
|
||||
|
||||
return $this->createUser($provider, $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $provider
|
||||
* @param \Laravel\Socialite\Contracts\User $sUser
|
||||
* @return \App\User
|
||||
*/
|
||||
protected function createUser($provider, $sUser)
|
||||
{
|
||||
$user = User::create([
|
||||
'name' => $sUser->getName(),
|
||||
'email' => $sUser->getEmail(),
|
||||
]);
|
||||
|
||||
$user->oauthProviders()->create([
|
||||
'provider' => $provider,
|
||||
'provider_user_id' => $sUser->getId(),
|
||||
'access_token' => $sUser->token,
|
||||
'refresh_token' => $sUser->refreshToken,
|
||||
]);
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\User;
|
||||
use App\Role;
|
||||
use App\Marking;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
use RegistersUsers;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* The user has been registered.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param mixed $user
|
||||
* @return mixed
|
||||
*/
|
||||
protected function registered(Request $request, $user)
|
||||
{
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'marking' => 'required|max:255|unique:markings',
|
||||
'email' => 'required|email|max:255|unique:users',
|
||||
'password' => 'required|min:6|confirmed',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return User
|
||||
*/
|
||||
protected function create(Request $data)
|
||||
{
|
||||
$this->validate($data, [
|
||||
'email' => 'required|email|max:255|unique:users',
|
||||
'password' => 'required|min:6|confirmed',
|
||||
]);
|
||||
|
||||
$marking = Marking::Where('email',$data['email'])->first();
|
||||
|
||||
if(!$marking){
|
||||
return response()->json(["message"=>"Marking does not exist, please contact sales team to get one"], 400);
|
||||
}
|
||||
if($marking->marking != strtoupper($data['marking'])){
|
||||
return response()->json(["message"=>"Incorrect marking"], 400);
|
||||
}
|
||||
|
||||
if(User::Where('email',$data['email'])->first()){
|
||||
return response()->json(["message"=>"Email already exist in the system"], 400);
|
||||
}
|
||||
|
||||
$role = Role::where('name','=','member')->first();
|
||||
$user = new User();
|
||||
$user->name = $data['name'];
|
||||
$user->email = $data['email'];
|
||||
$user->marking = $marking->marking;
|
||||
$user->password = bcrypt($data['password']);
|
||||
|
||||
$user->save();
|
||||
$user->attachRole($role);
|
||||
return response()->json($user, 201);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the response for a successful password reset.
|
||||
*
|
||||
* @param string $response
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
protected function sendResetResponse($response)
|
||||
{
|
||||
return ['status' => trans($response)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the response for a failed password reset.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string $response
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
protected function sendResetFailedResponse(Request $request, $response)
|
||||
{
|
||||
return response()->json(['email' => trans($response)], 400);
|
||||
}
|
||||
|
||||
protected function showResetForm(){
|
||||
return view('index');
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use App\SupplierBooking;
|
||||
use App\Booking;
|
||||
use App\Rate;
|
||||
use App\User;
|
||||
use App\UserBankSlip;
|
||||
use App\SettingBeneficiary;
|
||||
use App\SupplierBookingItem;
|
||||
use App\SettingSupplier;
|
||||
use App\SettingTaxRate;
|
||||
use App\SettingActiveBank;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BookingSupplierController extends Controller
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
$bookingsupplier = SupplierBooking::all();
|
||||
|
||||
$response = [
|
||||
'supplier-booking' => $bookingsupplier
|
||||
];
|
||||
|
||||
return response()->json($response, 200);
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$booking = Booking::where('id', $id)->first();
|
||||
$bankin_amount = round($booking->amount / $booking->rate, 2);
|
||||
|
||||
if (!$booking){
|
||||
return response()->json(['message' => 'Booking not found'], 404);
|
||||
}
|
||||
|
||||
switch ($booking->term) {
|
||||
case "x1_cash":
|
||||
$payment_method = "CASH";
|
||||
break;
|
||||
case "x1_cheque":
|
||||
|
||||
$payment_method = "CHEQUE";
|
||||
break;
|
||||
case "x1_ba":
|
||||
|
||||
$payment_method = "BA";
|
||||
break;
|
||||
case "x2_cash":
|
||||
|
||||
$payment_method = "CASH";
|
||||
break;
|
||||
case "x2_cheque":
|
||||
$payment_method = "CHEQUE";
|
||||
break;
|
||||
case "x2_ba":
|
||||
$payment_method = "BA";
|
||||
break;
|
||||
default:
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Invalid input',
|
||||
], 422);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$supplier_booking = $booking->supplierBooking()->first();
|
||||
$dt = new \DateTime($supplier_booking->created_at);
|
||||
$supplier_booking->date = $dt->format('j F Y');
|
||||
$supplier_booking->marking = $booking->user->marking;
|
||||
$supplier_booking->payment_for = $booking->payment_for;
|
||||
$supplier_booking->order_no = $booking->order_no;
|
||||
$supplier_booking->payment_method = $payment_method;
|
||||
|
||||
$active_bank = SettingActiveBank::first();
|
||||
|
||||
// if setting is set to use customer's beneficiary
|
||||
if ($active_bank->beneficiary_id == 0){
|
||||
$supplier_booking->acc_name = $booking->account_name;
|
||||
$supplier_booking->acc_no = $booking->account_num; // TODO : standardize acc_no
|
||||
$supplier_booking->bank_name = $booking->bank_name;
|
||||
$supplier_booking->bank_branch = $booking->bank_branch;
|
||||
}
|
||||
|
||||
else{
|
||||
$beneficiary = SettingBeneficiary::find($active_bank->beneficiary_id);
|
||||
$supplier_booking->acc_name = $beneficiary->company_name;
|
||||
$supplier_booking->acc_no = $beneficiary->acc_no;
|
||||
$supplier_booking->bank_name = $beneficiary->bank_name;
|
||||
$supplier_booking->bank_branch = $beneficiary->bank_branch;
|
||||
}
|
||||
|
||||
return response()->json($supplier_booking ,200);
|
||||
}
|
||||
|
||||
// Only for single booking
|
||||
// TODO : Multiple booking
|
||||
public function store(Request $request)
|
||||
{
|
||||
//$transfer_amount = $request->input("transfer_amount");
|
||||
$supplier_id = $request->input("supplier_id");
|
||||
$booking_id = $request->input("booking_id");
|
||||
$rate = $request->input('rate'); // costing rate
|
||||
$rebate = $request->input('rebate');
|
||||
$supplier = SettingSupplier::find($supplier_id);
|
||||
$booking = Booking::find($booking_id);
|
||||
|
||||
|
||||
|
||||
// Calculation (backup)
|
||||
// $amountInRMB = $transfer_amount * $rate;
|
||||
// $billing = 0.015 * $transfer_amount;
|
||||
// $sales_tax = 0.0 * $transfer_amount;
|
||||
// $gst = 0 * $transfer_amount; // do we still need this ?
|
||||
// $customerBankInAmount = round($transfer_amount + $gst + $sales_tax + $billing,2);
|
||||
// $rmbBankAmount = round($customerBankInAmount + $rebate, 2);
|
||||
|
||||
// Update: changes in 1.1 according to new supplier booking report
|
||||
$transfer_amount = $booking->amount;
|
||||
|
||||
$amount_in_myr = round($transfer_amount / $rate, 2);
|
||||
$amountInRMB = $transfer_amount;
|
||||
$tax_rate = SettingTaxRate::latest()->first()->tax_rate;
|
||||
$sales_tax = round($tax_rate * $amount_in_myr - $amount_in_myr, 2);
|
||||
$amount_after_tax = round($amount_in_myr * $tax_rate,2);
|
||||
//$billing = 0.015 * $transfer_amount;
|
||||
//
|
||||
//$gst = 0 * $transfer_amount; // do we still need this ?
|
||||
//$customerBankInAmount = round($transfer_amount + $gst + $sales_tax + $billing,2);
|
||||
//$rmbBankAmount = round($customerBankInAmount + $rebate, 2);
|
||||
|
||||
// update existing booking supplier if exist
|
||||
$bookingsupplier = SupplierBooking::where('booking_id', $booking_id)->first();
|
||||
|
||||
if (!$bookingsupplier){
|
||||
$bookingsupplier = new SupplierBooking();
|
||||
}
|
||||
|
||||
$bookingsupplier->supplier_id = $supplier->id;
|
||||
$bookingsupplier->amountInRMB = $amountInRMB; // TODO : rename to underscore
|
||||
$bookingsupplier->amount_in_myr = $amount_in_myr;
|
||||
$bookingsupplier->tax_rate = $tax_rate;
|
||||
$bookingsupplier->amount_after_tax = $amount_after_tax;
|
||||
$bookingsupplier->rate = $rate;
|
||||
$bookingsupplier->rebate = $rebate;
|
||||
$bookingsupplier->salestax_amount = $sales_tax;
|
||||
//$bookingsupplier->payment_method = $request->input('payment_method'); // TODO : remove from db
|
||||
//$bookingsupplier->transfer_amount = $transfer_amount; // TODO : remove from db
|
||||
//$bookingsupplier->billing_amount = $billing; // TODO : remove from db
|
||||
|
||||
//$bookingsupplier->rmbBankAmount = $rmbBankAmount; // TODO : remove from db
|
||||
$bookingsupplier->booking_id = $booking->id;
|
||||
$bookingsupplier->save();
|
||||
|
||||
// update booking status
|
||||
$booking->status = 4;
|
||||
$booking->admin_status = 4;
|
||||
$booking->save();
|
||||
|
||||
|
||||
|
||||
return response()->json($bookingsupplier, 201);
|
||||
}
|
||||
|
||||
public function report(Request $request, $id)
|
||||
{
|
||||
$supplier_booking = Booking::firstOrFail($id)->supplierBooking()->firstOrFail();
|
||||
|
||||
return response()->json($supplier_booking ,200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\ChinaBankSlip;
|
||||
use App\Booking;
|
||||
use App\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Validator;
|
||||
|
||||
class ChinaBankSlipController extends Controller
|
||||
{
|
||||
|
||||
public function store(Request $request, $id)
|
||||
{
|
||||
$booking = Booking::where('id',$id)->firstOrFail();
|
||||
|
||||
if (!$booking) {
|
||||
return response()->json(['message'=>'Access denied'], 403);
|
||||
}
|
||||
|
||||
// TODO : put this after check file exist
|
||||
// validate file format
|
||||
$validator = Validator::make($request->all(), [
|
||||
'file' => 'mimes:jpg,jpeg,bmp,png,xls,xlsx,doc,docx,pdf'
|
||||
]);
|
||||
|
||||
if($validator->fails()){
|
||||
return response()->json(['message'=>'Incorrect format'],400);
|
||||
}
|
||||
|
||||
$validator = Validator::make($request->all(), [
|
||||
'china_bank_slips' => 'max:10000'
|
||||
]);
|
||||
|
||||
if($validator->fails()){
|
||||
return response()->json(['message'=>'Image too large, upload files up to 3 MB'], 400);
|
||||
}
|
||||
|
||||
if($bankslip_file = $request->file('file')){
|
||||
$filename = $bankslip_file->getClientOriginalName();
|
||||
$ext = $bankslip_file->getClientOriginalExtension();
|
||||
$unique_name = 'cnbank_slip_' . md5($filename. time()); // probably not a good idea
|
||||
$unique_image_path = $unique_name. '.' .$ext;
|
||||
|
||||
// Upload Image
|
||||
$upload_path = Storage::disk('public')->putFileAs(
|
||||
'china_bank_slip', $bankslip_file, $unique_image_path
|
||||
);
|
||||
|
||||
|
||||
} else {
|
||||
return response()->json(['message'=>'file not found'],200);
|
||||
}
|
||||
|
||||
$china_bankslip = new ChinaBankSlip;
|
||||
$china_bankslip->booking_id = $booking->id;
|
||||
$china_bankslip->china_bank_slip_path = $upload_path;
|
||||
$china_bankslip->save();
|
||||
|
||||
return response()->json(['message'=>'success'], 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, $id){
|
||||
$booking = Booking::where('id',$id)->first();
|
||||
$china_bankslip = $booking->chinaBankSlip()->first();
|
||||
|
||||
// TODO: first or fail
|
||||
if(!$china_bankslip){
|
||||
return response()->json(["message"=> "China bankslip not found. Please upload first."],400);
|
||||
}
|
||||
|
||||
$china_bankslip->actual_transfer_amount = $request->input('actual_transfer_amount');
|
||||
$china_bankslip->date = $request->input('date');
|
||||
$china_bankslip->details = $request->input('details');
|
||||
$china_bankslip->save();
|
||||
|
||||
// update booking status
|
||||
$booking->status = 5;
|
||||
$booking->admin_status = 6;
|
||||
$booking->save();
|
||||
|
||||
return response()->json(["message"=> "Success"],200);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('home');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Marking;
|
||||
|
||||
class MarkingController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return Marking::all();
|
||||
}
|
||||
|
||||
public function show(Marking $marking)
|
||||
{
|
||||
return $marking;
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$marking = new Marking;
|
||||
$marking->marking = strtoupper($request->input('marking'));
|
||||
$marking->email = $request->input('email');
|
||||
$marking->save();
|
||||
|
||||
return response()->json($marking, 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, Marking $marking)
|
||||
{
|
||||
// TODO : update to upper case
|
||||
$marking->update($request->all());
|
||||
|
||||
return response()->json($marking, 200);
|
||||
}
|
||||
|
||||
public function delete(Marking $marking)
|
||||
{
|
||||
$marking->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Notification;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Auth;
|
||||
|
||||
class NotificationController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return Notification::all()->orderby('updated_at','desc');
|
||||
}
|
||||
|
||||
public function show(Notification $notification)
|
||||
{
|
||||
return $notification;
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$notification = Notification::create($request->all());
|
||||
|
||||
return response()->json($notification, 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, Notification $notification)
|
||||
{
|
||||
$notification->update($request->all());
|
||||
|
||||
return response()->json($notification, 200);
|
||||
}
|
||||
|
||||
public function delete(Notification $notification)
|
||||
{
|
||||
$notification->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
|
||||
public function getUserMessage()
|
||||
{
|
||||
$user_all_notification = Notification::Where("user_id",Auth::user()->id)
|
||||
->orderby('updated_at','desc')
|
||||
->paginate(5);
|
||||
$user_unread_notification = Notification::Where([["user_id",Auth::user()->id],["is_read",0]])
|
||||
->orderby('updated_at','desc')
|
||||
->get();
|
||||
|
||||
return response()->json([
|
||||
"message" =>$user_all_notification,
|
||||
"unread_message" =>$user_unread_notification
|
||||
],200);
|
||||
}
|
||||
|
||||
public function readNotification($notification_id){
|
||||
$affected = DB::table('notifications')
|
||||
->Where('id', $notification_id)
|
||||
->update(array('is_read' => 1));
|
||||
return response()->json("Read message", 200);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Rate;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RateController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return Rate::all();
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$rate = Rate::create($request->all());
|
||||
|
||||
return response()->json($rate, 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, Rate $rate)
|
||||
{
|
||||
$rate->update($request->all());
|
||||
|
||||
return response()->json($rate, 200);
|
||||
}
|
||||
|
||||
public function delete(Rate $rate)
|
||||
{
|
||||
$rate->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
|
||||
public function show()
|
||||
{
|
||||
$rate = Rate::latest()->first();
|
||||
|
||||
return response()->json($rate, 200);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\SettingActiveBank;
|
||||
|
||||
class SettingActiveBankController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$active_bank_setting = SettingActiveBank::latest()->first();
|
||||
return response()->json($active_bank_setting, 200);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
if($active_bank_setting = SettingActiveBank::latest()->first())
|
||||
$active_bank_setting->update($request->all());
|
||||
else
|
||||
$active_bank_setting = SettingActiveBank::create($request->all());
|
||||
|
||||
return response()->json($active_bank_setting, 200);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\SettingBeneficiary;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SettingBeneficiaryController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return SettingBeneficiary::all();
|
||||
}
|
||||
|
||||
public function show($beneficiary)
|
||||
{
|
||||
if ($beneficiary == 0){
|
||||
response()->json(["company_name"=>"123", "account_number"=>"123"] , 201);
|
||||
}
|
||||
$beneficiary = SettingBeneficiary::find($beneficiary);
|
||||
return $beneficiary;
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$beneficiary = SettingBeneficiary::create($request->all());
|
||||
|
||||
return response()->json($beneficiary, 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, SettingBeneficiary $beneficiary)
|
||||
{
|
||||
$beneficiary->update($request->all());
|
||||
|
||||
return response()->json($beneficiary, 200);
|
||||
}
|
||||
|
||||
public function delete(SettingBeneficiary $beneficiary)
|
||||
{
|
||||
$beneficiary->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\SettingBillingCharge;
|
||||
|
||||
class SettingBillingChargeController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$billing_charge_setting = SettingBillingCharge::latest()->first();
|
||||
return response()->json($billing_charge_setting, 201);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
if($billing_charge_setting = SettingBillingCharge::latest()->first())
|
||||
$billing_charge_setting->update($request->all());
|
||||
else
|
||||
$billing_charge_setting = SettingBillingCharge::create($request->all());
|
||||
|
||||
return response()->json($billing_charge_setting, 200);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\SettingCredit;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SettingCreditController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$credit_setting = SettingCredit::latest()->first();
|
||||
return response()->json($credit_setting, 201);
|
||||
}
|
||||
|
||||
public function show(SettingCredit $credit)
|
||||
{
|
||||
return $credit;
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$credit = SettingCredit::create($request->all());
|
||||
|
||||
return response()->json($credit, 201);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
$credit_setting = SettingCredit::latest()->first();
|
||||
$credit_setting->update($request->all());
|
||||
|
||||
return response()->json($credit_setting, 200);
|
||||
}
|
||||
|
||||
public function delete(SettingCredit $credit)
|
||||
{
|
||||
$credit->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\SettingMalaysiaBank;
|
||||
|
||||
class SettingMalaysiaBankController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return SettingMalaysiaBank::all();
|
||||
}
|
||||
|
||||
public function show(SettingMalaysiaBank $malaysiaBank)
|
||||
{
|
||||
return $malaysiaBank;
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$malaysiaBank = SettingMalaysiaBank::create($request->all());
|
||||
|
||||
return response()->json($malaysiaBank, 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, SettingMalaysiaBank $malaysiaBank)
|
||||
{
|
||||
$malaysiaBank->update($request->all());
|
||||
|
||||
return response()->json($malaysiaBank, 200);
|
||||
}
|
||||
|
||||
public function delete(SettingMalaysiaBank $malaysiaBank)
|
||||
{
|
||||
$malaysiaBank->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\SettingSupplier;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SettingSupplierController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$suppliers = SettingSupplier::all();
|
||||
|
||||
foreach ($suppliers as $supplier) {
|
||||
$supplier->value = $supplier->id;
|
||||
$supplier->label = $supplier->company_name;
|
||||
}
|
||||
return $suppliers;
|
||||
}
|
||||
|
||||
public function show(SettingSupplier $supplier)
|
||||
{
|
||||
return $supplier;
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$supplier = SettingSupplier::create($request->all());
|
||||
|
||||
return response()->json($supplier, 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, SettingSupplier $supplier)
|
||||
{
|
||||
$supplier->update($request->all());
|
||||
|
||||
return response()->json($supplier, 200);
|
||||
}
|
||||
|
||||
public function delete(SettingSupplier $supplier)
|
||||
{
|
||||
$supplier->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\SettingTaxRate;
|
||||
|
||||
class SettingTaxRateController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$setting_tax = SettingTaxRate::latest()->first();
|
||||
return response()->json($setting_tax, 201);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
if($setting_tax = SettingTaxRate::latest()->first())
|
||||
$setting_tax->update($request->all());
|
||||
else
|
||||
$setting_tax = SettingTaxRate::create($request->all());
|
||||
|
||||
return response()->json($setting_tax, 200);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class PasswordController extends Controller
|
||||
{
|
||||
/**
|
||||
* Update the user's password.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'password' => 'required|confirmed|min:6',
|
||||
]);
|
||||
|
||||
$request->user()->update([
|
||||
'password' => bcrypt($request->password),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
/**
|
||||
* Update the user's profile information.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
$this->validate($request, [
|
||||
'name' => 'required',
|
||||
'email' => 'required|email|unique:users,email,'.$user->id,
|
||||
]);
|
||||
|
||||
return tap($user)->update($request->only('name', 'email'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\ChinaBankSlip $chinaBankSlip
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Request $request)
|
||||
{
|
||||
|
||||
$user = Auth::user();
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class WelcomeController extends Controller
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\ChinaBankSlip $chinaBankSlip
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('index');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\App\Http\Middleware\SetLocale::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
// \App\Http\Middleware\EncryptCookies::class,
|
||||
// \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
// \Illuminate\Session\Middleware\StartSession::class,
|
||||
// \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
// \Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
// \App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
// 'throttle:60,1',
|
||||
'bindings',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'ability' => 'App\Http\Middleware\TokenEntrustAbility',
|
||||
'role' => \Zizaco\Entrust\Middleware\EntrustRole::class,
|
||||
'permission' => \Zizaco\Entrust\Middleware\EntrustPermission::class,
|
||||
'jwt' => \App\Http\Middleware\RefreshToken::class,
|
||||
'ability' => 'App\Http\Middleware\TokenEntrustAbility'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $guard
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
{
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return response()->json(['error' => 'Already authenticated.'], 400);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
class SetLocale
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($locale = $this->parseLocale($request)) {
|
||||
app()->setLocale($locale);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return string|null
|
||||
*/
|
||||
protected function parseLocale($request)
|
||||
{
|
||||
$locales = config('app.locales');
|
||||
|
||||
$locale = $request->server('HTTP_ACCEPT_LANGUAGE');
|
||||
$locale = substr($locale, 0, strpos($locale, ',') ?: strlen($locale));
|
||||
|
||||
if (array_key_exists($locale, $locales)) {
|
||||
return $locale;
|
||||
}
|
||||
|
||||
if (array_key_exists($locale, $locales)) {
|
||||
return $locale;
|
||||
}
|
||||
|
||||
$locale = substr($locale, 0, 2);
|
||||
if (array_key_exists($locale, $locales)) {
|
||||
return $locale;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Tymon\JWTAuth\Exceptions\JWTException;
|
||||
use Tymon\JWTAuth\Exceptions\TokenExpiredException;
|
||||
use Tymon\JWTAuth\Http\Middleware\BaseMiddleware;
|
||||
|
||||
class TokenEntrustAbility extends BaseMiddleware
|
||||
{
|
||||
public function handle($request, Closure $next, $roles, $permissions, $validateAll = false)
|
||||
{
|
||||
|
||||
if (! $token = $this->auth->setRequest($request)->getToken()) {
|
||||
return $this->respond('tymon.jwt.absent', 'token_not_provided', 400);
|
||||
}
|
||||
|
||||
try {
|
||||
$user = $this->auth->authenticate($token);
|
||||
} catch (TokenExpiredException $e) {
|
||||
return $this->respond('tymon.jwt.expired', 'token_expired', $e->getStatusCode(), [$e]);
|
||||
} catch (JWTException $e) {
|
||||
return $this->respond('tymon.jwt.invalid', 'token_invalid', $e->getStatusCode(), [$e]);
|
||||
}
|
||||
|
||||
if (! $user) {
|
||||
return $this->respond('tymon.jwt.user_not_found', 'user_not_found', 404);
|
||||
}
|
||||
|
||||
if (!$request->user()->ability(explode('|', $roles), explode('|', $permissions), array('validate_all' => $validateAll))) {
|
||||
return $this->respond('tymon.jwt.invalid', 'token_invalid', 401, 'Unauthorized');
|
||||
}
|
||||
|
||||
$this->events->fire('tymon.jwt.valid', $user);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Fideloper\Proxy\TrustProxies as Middleware;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The current proxy header mappings.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $headers = Request::HEADER_X_FORWARDED_ALL;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Invoice extends Model
|
||||
{
|
||||
protected $fillable = ['invoice_url','amount','booking_id'];
|
||||
|
||||
public function booking(){
|
||||
return $this->hasOne('App\Booking');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Marking extends Model
|
||||
{
|
||||
protected $fillable = ['email','marking'];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('app\User');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Notification extends Model
|
||||
{
|
||||
protected $fillable = ['detail','user_id','is_read'];
|
||||
protected $appends = ['time_interval'];
|
||||
|
||||
public function getTimeIntervalAttribute()
|
||||
{
|
||||
$created_time = $this->created_at;
|
||||
|
||||
date_default_timezone_set('Asia/Kuala_Lumpur'); //Change as per your default time
|
||||
$str = strtotime($created_time);
|
||||
$today = strtotime(date('Y-m-d H:i:s'));
|
||||
|
||||
// It returns the time difference in Seconds...
|
||||
$time_differnce = $today-$str;
|
||||
|
||||
// To Calculate the time difference in Years...
|
||||
$years = 60*60*24*365;
|
||||
|
||||
// To Calculate the time difference in Months...
|
||||
$months = 60*60*24*30;
|
||||
|
||||
// To Calculate the time difference in Days...
|
||||
$days = 60*60*24;
|
||||
|
||||
// To Calculate the time difference in Hours...
|
||||
$hours = 60*60;
|
||||
|
||||
// To Calculate the time difference in Minutes...
|
||||
$minutes = 60;
|
||||
|
||||
if(intval($time_differnce/$years) > 1)
|
||||
{
|
||||
return intval($time_differnce/$years)." years ago";
|
||||
}else if(intval($time_differnce/$years) > 0)
|
||||
{
|
||||
return intval($time_differnce/$years)." year ago";
|
||||
}else if(intval($time_differnce/$months) > 1)
|
||||
{
|
||||
return intval($time_differnce/$months)." months ago";
|
||||
}else if(intval(($time_differnce/$months)) > 0)
|
||||
{
|
||||
return intval(($time_differnce/$months))." month ago";
|
||||
}else if(intval(($time_differnce/$days)) > 1)
|
||||
{
|
||||
return intval(($time_differnce/$days))." days ago";
|
||||
}else if (intval(($time_differnce/$days)) > 0)
|
||||
{
|
||||
return intval(($time_differnce/$days))." day ago";
|
||||
}else if (intval(($time_differnce/$hours)) > 1)
|
||||
{
|
||||
return intval(($time_differnce/$hours))." hours ago";
|
||||
}else if (intval(($time_differnce/$hours)) > 0)
|
||||
{
|
||||
return intval(($time_differnce/$hours))." hour ago";
|
||||
}else if (intval(($time_differnce/$minutes)) > 1)
|
||||
{
|
||||
return intval(($time_differnce/$minutes))." minutes ago";
|
||||
}else if (intval(($time_differnce/$minutes)) > 0)
|
||||
{
|
||||
return intval(($time_differnce/$minutes))." minute ago";
|
||||
}else if (intval(($time_differnce)) > 1)
|
||||
{
|
||||
return intval(($time_differnce))." seconds ago";
|
||||
}else
|
||||
{
|
||||
return "few seconds ago";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Auth\Notifications\ResetPassword as Notification;
|
||||
|
||||
class ResetPassword extends Notification
|
||||
{
|
||||
/**
|
||||
* Build the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
return (new MailMessage)
|
||||
->line('You are receiving this email because we received a password reset request for your account.')
|
||||
->action('Reset Password', url(config('app.url').'/password/reset/'.$this->token).'?email='.urlencode($notifiable->email))
|
||||
->line('If you did not request a password reset, no further action is required.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class OAuthProvider extends Model
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'oauth_providers';
|
||||
|
||||
/**
|
||||
* The attributes that aren't mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = ['id'];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'access_token', 'refresh_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Rate;
|
||||
use App\User;
|
||||
use App\Events\RateUpdated;
|
||||
|
||||
class RateObserver
|
||||
{
|
||||
/**
|
||||
* Handle the rate "created" event.
|
||||
*
|
||||
* @param \App\Rate $rate
|
||||
* @return void
|
||||
*/
|
||||
public function created(Rate $rate)
|
||||
{
|
||||
event(new RateUpdated($rate));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php namespace App;
|
||||
|
||||
use Zizaco\Entrust\EntrustPermission;
|
||||
|
||||
class Permission extends EntrustPermission
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Laravel\Dusk\DuskServiceProvider;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use App\Observers\RateObserver;
|
||||
use App\Rate;
|
||||
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
/*
|
||||
if ($this->app->runningUnitTests()) {
|
||||
Schema::defaultStringLength(191);
|
||||
}
|
||||
*/
|
||||
Rate::observe(RateObserver::class);
|
||||
Schema::defaultStringLength(191);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
if ($this->app->environment('local', 'testing')) {
|
||||
$this->app->register(DuskServiceProvider::class);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The policy mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $policies = [
|
||||
'App\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->registerPolicies();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//Broadcast::routes();
|
||||
Broadcast::routes(["middleware" => ["auth:api"]]);
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event listener mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $listen = [
|
||||
'App\Events\Event' => [
|
||||
'App\Listeners\EventListener',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* This namespace is applied to your controller routes.
|
||||
*
|
||||
* In addition, it is set as the URL generator's root namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'App\Http\Controllers';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map()
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapWebRoutes()
|
||||
{
|
||||
Route::middleware('web')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapApiRoutes()
|
||||
{
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/api.php'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PurchaseOrder extends Model
|
||||
{
|
||||
protected $fillable = ['image_url','amount','booking_id'];
|
||||
|
||||
public function booking()
|
||||
{
|
||||
return $this->belongsTo(Booking::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Rate extends Model
|
||||
{
|
||||
protected $fillable = ['x1_cash','x1_cheque','x1_ba','x2_cash','x2_cheque','x2_ba'];
|
||||
protected $hidden = ['id'];
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php namespace App;
|
||||
|
||||
use Zizaco\Entrust\EntrustRole;
|
||||
|
||||
class Role extends EntrustRole
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SettingActiveBank extends Model
|
||||
{
|
||||
protected $fillable = ['x1_bank_id','x2_bank_id','beneficiary_id'];
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SettingBeneficiary extends Model
|
||||
{
|
||||
protected $fillable = ['company_name','bank_name','acc_no','bank_address','swift','cnap','bank_branch'];
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SettingBillingCharge extends Model
|
||||
{
|
||||
protected $fillable = ['billing_charge_rate'];
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SettingCredit extends Model
|
||||
{
|
||||
protected $fillable = ['rmb_credit_limit','usd_credit_limit','time_limit'];
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SettingMalaysiaBank extends Model
|
||||
{
|
||||
protected $fillable = ['company_name','bank_name','acc_no','bank_address','swift','cnap','bank_branch'];
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SettingSupplier extends Model
|
||||
{
|
||||
protected $fillable = ['company_name','gst_no','supplier_reg_no','bank_name','acc_no'];
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SettingTaxRate extends Model
|
||||
{
|
||||
protected $fillable = ['tax_rate'];
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SupplierBooking extends Model
|
||||
{
|
||||
// protected $guarded = [];
|
||||
protected $fillable = ['rate','rebate','payment_amount','payment_method'];
|
||||
public $timestamps = true;
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('app\User');
|
||||
}
|
||||
|
||||
public function booking(){
|
||||
return $this->belongTo('App\Booking');
|
||||
}
|
||||
|
||||
public function supplierBookingTtem()
|
||||
{
|
||||
return $this->hasMany('App\SupplierBookingItem');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SupplierBookingItem extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'china_bankslip_url',
|
||||
'book_id',
|
||||
'bank_in_amount',
|
||||
'date',
|
||||
'details',
|
||||
'supplierbooking_id'
|
||||
];
|
||||
|
||||
public function bookingsupplier()
|
||||
{
|
||||
return $this->belongsTo('App\BookingSupplier');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Tymon\JWTAuth\Contracts\JWTSubject;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use App\Notifications\ResetPassword as ResetPasswordNotification;
|
||||
use Zizaco\Entrust\Traits\EntrustUserTrait;
|
||||
|
||||
|
||||
class User extends Authenticatable implements JWTSubject
|
||||
{
|
||||
use Notifiable;
|
||||
use EntrustUserTrait;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name', 'email', 'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password', 'remember_token'
|
||||
];
|
||||
|
||||
/**
|
||||
* The accessors to append to the model's array form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $appends = [
|
||||
'photo_url', 'role'
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the profile photo URL attribute.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPhotoUrlAttribute()
|
||||
{
|
||||
return 'https://www.gravatar.com/avatar/'.md5(strtolower($this->email)).'.jpg?s=200&d=mm';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the role attribute.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRoleAttribute()
|
||||
{
|
||||
return $this->roles->first()->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the oauth providers.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function oauthProviders()
|
||||
{
|
||||
return $this->hasMany(OAuthProvider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the password reset notification.
|
||||
*
|
||||
* @param string $token
|
||||
* @return void
|
||||
*/
|
||||
public function sendPasswordResetNotification($token)
|
||||
{
|
||||
$this->notify(new ResetPasswordNotification($token));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getJWTIdentifier()
|
||||
{
|
||||
return $this->getKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getJWTCustomClaims()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function bookings(){
|
||||
return $this->hasMany(Booking::class);
|
||||
}
|
||||
|
||||
public function marking(){
|
||||
return $this->hasOne(Booking::class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserBankSlip extends Model
|
||||
{
|
||||
protected $fillable = ['bank_slip_type','bankslip_url','transfer_amount','booking_id','cust_marking'];
|
||||
|
||||
public function booking()
|
||||
{
|
||||
return $this->belongsTo(Booking::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user