fix pargar
This commit is contained in:
@@ -59,7 +59,8 @@ class PargarInboundController extends Controller
|
||||
|
||||
public function upsertCustomers(Request $request)
|
||||
{
|
||||
$customers = $request->input('Customers', []);
|
||||
$payload = $this->pargarPayload($request);
|
||||
$customers = $payload['Customers'] ?? [];
|
||||
if (! is_array($customers) || $customers === []) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
@@ -209,7 +210,8 @@ class PargarInboundController extends Controller
|
||||
|
||||
public function confirmOrders(Request $request)
|
||||
{
|
||||
$orderIds = $request->input('OrderIds', []);
|
||||
$payload = $this->pargarPayload($request);
|
||||
$orderIds = $payload['OrderIds'] ?? [];
|
||||
if (! is_array($orderIds)) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
@@ -229,7 +231,7 @@ class PargarInboundController extends Controller
|
||||
|
||||
public function storeDocuments(Request $request)
|
||||
{
|
||||
$data = $request->all();
|
||||
$data = $this->pargarPayload($request);
|
||||
$accountId = trim((string) ($data['accountId'] ?? ''));
|
||||
$transactions = $data['transactions'] ?? [];
|
||||
|
||||
@@ -255,7 +257,7 @@ class PargarInboundController extends Controller
|
||||
|
||||
public function storeMande(Request $request)
|
||||
{
|
||||
$data = $request->all();
|
||||
$data = $this->pargarPayload($request);
|
||||
$accountId = trim((string) ($data['AccountId'] ?? ''));
|
||||
|
||||
$customer = Customer::where('pargar_account_id', $accountId)->first();
|
||||
@@ -343,7 +345,8 @@ class PargarInboundController extends Controller
|
||||
|
||||
public function confirmCustomers(Request $request)
|
||||
{
|
||||
$rows = $request->input('customers', []);
|
||||
$payload = $this->pargarPayload($request);
|
||||
$rows = $payload['customers'] ?? [];
|
||||
if (! is_array($rows)) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
@@ -393,23 +396,29 @@ class PargarInboundController extends Controller
|
||||
*/
|
||||
private function pargarLoginCredentials(Request $request): array
|
||||
{
|
||||
$username = (string) $request->input('username', '');
|
||||
$password = (string) $request->input('password', '');
|
||||
|
||||
if ($username === '' && $password === '') {
|
||||
$payload = json_decode((string) $request->getContent(), true);
|
||||
if (is_array($payload)) {
|
||||
$username = (string) ($payload['username'] ?? '');
|
||||
$password = (string) ($payload['password'] ?? '');
|
||||
}
|
||||
}
|
||||
$payload = $this->pargarPayload($request);
|
||||
|
||||
return [
|
||||
$this->normalizeCredential($username),
|
||||
$this->normalizeCredential($password),
|
||||
$this->normalizeCredential((string) ($payload['username'] ?? '')),
|
||||
$this->normalizeCredential((string) ($payload['password'] ?? '')),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function pargarPayload(Request $request): array
|
||||
{
|
||||
$payload = $request->all();
|
||||
if ($payload !== []) {
|
||||
return $payload;
|
||||
}
|
||||
|
||||
$decoded = json_decode((string) $request->getContent(), true);
|
||||
|
||||
return is_array($decoded) ? $decoded : [];
|
||||
}
|
||||
|
||||
private function normalizeCredential(string $value): string
|
||||
{
|
||||
$persian = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
|
||||
|
||||
Reference in New Issue
Block a user