mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-23 14:34:19 +00:00
initial commit for ShippingEstimationCalculator
This commit is contained in:
+54
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
|
||||
use App\Models\Document;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class ShippingEstimationCalculatorLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Shipping estimation',
|
||||
'message' => 'You have successfully calculate the Shipping Estimation'
|
||||
];
|
||||
}
|
||||
|
||||
public function __construct(){}
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$base_price = 0;
|
||||
$warehouse_rate = 0;
|
||||
$state_rate = 0;
|
||||
$state_select = '';
|
||||
|
||||
$width = $request->input('width') / 100; // metre
|
||||
$length = $request->input('length') / 100; // metre
|
||||
$height = $request->input('height') / 100; // metre
|
||||
|
||||
$dimension = (float) ($width * $length * $height);
|
||||
|
||||
return $this->response([
|
||||
'width' => $width, 'length' => $length, 'height' => $height,
|
||||
'dimension' => $dimension
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\ShippingEstimationCalculatorLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ShippingEstimationCalculatorController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ShippingEstimationCalculatorLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function calculate(Request $request, ShippingEstimationCalculatorLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,8 @@ Route::group(['prefix' => 'transactions', 'namespace' => 'Transactions', 'as' =>
|
||||
|
||||
route::post('/shipping-invoice/create', 'CreateShippingInvoiceTransactionController@create')->name('supplier.create');
|
||||
|
||||
route::post('/shipping-invoice/calculator', 'ShippingEstimationCalculatorController@calculate')->name('shipping.estimation.calculator');
|
||||
|
||||
// Route::group(['prefix' => '{id}/payment', 'as' => 'payment.'], function () {
|
||||
// Route::post('quotation', 'FetchBookingPaymentQuotationController@fetch')->name('quotation');
|
||||
// Route::post('create', 'CreateBookingPaymentController@create')->name('create');
|
||||
|
||||
Reference in New Issue
Block a user