online transaction
This commit is contained in:
@@ -30,7 +30,7 @@ class CustomerController extends Controller
|
|||||||
public function getLatestCustomer($kodcaw){
|
public function getLatestCustomer($kodcaw){
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||||
|
|
||||||
$customer = Customer::on($cawangan['mysql'])->orderBy('nosiri','desc')->first();
|
$customer = Customer::on($cawangan['mysql'])->orderBy('tarikh','desc')->orderBy('nosiri','desc')->first();
|
||||||
|
|
||||||
return response()->json($customer);
|
return response()->json($customer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\TransactionOnline;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
class TransactionOnlineController extends Controller
|
||||||
|
{
|
||||||
|
public function getLatestNosiri(){
|
||||||
|
$current = Carbon::now();
|
||||||
|
$current = new Carbon();
|
||||||
|
|
||||||
|
$nosiri = TransactionOnline::on('mysql7')->where('tarikh','=',$current->toDateString())->orderBy('nosiri','desc')->first();
|
||||||
|
|
||||||
|
return response()->json($nosiri);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(Request $request){
|
||||||
|
$current = Carbon::now();
|
||||||
|
$current = new Carbon();
|
||||||
|
|
||||||
|
$transaction = TransactionOnline::on('mysql7')->create([
|
||||||
|
'nokp' => $request->nokp,
|
||||||
|
'reference_no' => $request->reference_no,
|
||||||
|
'nosiri' => $request->nosiri,
|
||||||
|
'total_payment' => $request->total_payment,
|
||||||
|
'tarikh' => $current->toDateString(),
|
||||||
|
'masa' => $current->toTimeString()
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response()->json($transaction,201);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class TransactionOnline extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'transaction_online';
|
||||||
|
public $timestamps = false;
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'nokp','reference_no','nosiri','total_payment','tarikh','masa','status'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes excluded from the model's JSON form.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
// protected $hidden = [];
|
||||||
|
}
|
||||||
@@ -129,4 +129,8 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
|||||||
$router->get('otp/{nokp}',['uses'=>'OtpController@getOtp']);
|
$router->get('otp/{nokp}',['uses'=>'OtpController@getOtp']);
|
||||||
$router->get('otp/check/{otp_token}',['uses'=>'OtpController@checkToken']);
|
$router->get('otp/check/{otp_token}',['uses'=>'OtpController@checkToken']);
|
||||||
$router->put('otp/update_otp',['uses'=>'OtpController@usedOTP']);
|
$router->put('otp/update_otp',['uses'=>'OtpController@usedOTP']);
|
||||||
|
|
||||||
|
//Online Transaction
|
||||||
|
$router->get('online/transaction',['uses'=>'TransactionOnlineController@getLatestNosiri']);
|
||||||
|
$router->post('online/transaction',['uses'=>'TransactionOnlineController@create']);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user