initial commit for ShippingEstimationCalculator

This commit is contained in:
marjuqi@ad
2022-05-17 15:31:17 +07:00
parent e1ee96f77c
commit d4c35a5286
3 changed files with 76 additions and 0 deletions
@@ -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);
}
}
+2
View File
@@ -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');