birzha/plugins/ahmadfatoni/apigenerator/controllers/api/BanksApiController.php

54 lines
1.6 KiB
PHP

<?php namespace AhmadFatoni\ApiGenerator\Controllers\API;
use Cms\Classes\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Validator;
use TPS\Birzha\Models\Settings;
class BanksApiController extends Controller
{
protected $localeRules;
protected $data;
protected $validator;
public function __construct(Request $request)
{
$this->localeRules = ['locale' => 'required|in:ru,tm,en'];
$this->data = $request->only(['locale']);
$this->validator = Validator::make($this->data, $this->localeRules);
}
public function getBankInfo()
{
if($this->validator->fails()) {
return response()->json($this->validator->errors(), 400);
}
return response()->json([
'tax_code' => Settings::getValue('tax_code'),
'bab' => Settings::getValue('bab'),
'manat_account' => Settings::getValue('manat_account'),
'correspondent_account' => Settings::getValue('correspondent_account'),
'bank_address' => trans("validation.api.bank_address_one", [], $this->data['locale'])
], 200);
}
public function getBankTypes()
{
if($this->validator->fails()) {
return response()->json($this->validator->errors(), 400);
}
$banks = [];
$i = 0;
foreach (Config::get('bank') as $bank) {
$banks[$i]['api_val'] = $bank['api_val'];
$banks[$i]['name'] = $bank['trans'][$this->data['locale']];
$i++;
}
return response()->json($banks, 200);
}
}