This commit is contained in:
2025-06-23 15:20:43 +05:00
parent df985789f1
commit 571b422454
7 changed files with 349 additions and 3 deletions

View File

@@ -0,0 +1,58 @@
<?php
namespace App\Http\Controllers\Api\CardPin\Requests;
use App\Repos\Order\OrderRepo;
use App\Repos\System\Settings\Location\RegionRepo;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin \App\Models\Order\Card\CardPin\CardPin
*/
class CardPinIndexResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'unique_id' => $this->unique_id,
'card_type_id' => $this->cardType?->name,
'card_number' => $this->card_number,
'region' => RegionRepo::label($this->region),
'branch_id' => $this->branch?->name,
'customer_name' => $this->customer_name,
'customer_surname' => $this->customer_surname,
'customer_patronic_name' => $this->customer_patronic_name,
'born_at' => $this->born_at,
'phone' => $this->phone,
'status' => OrderRepo::statusFormatted($this->status),
'passport_serie' => $this->passport_serie,
'passport_id' => $this->passport_id,
'passport_one' => url('/storage/'.$this->passport_one),
'passport_two' => url('/storage/'.$this->passport_two),
'passport_three' => url('/storage/'.$this->passport_three),
'passport_four' => url('/storage/'.$this->passport_four),
'notes' => $this->notes,
'user_id' => $this->user_id,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'deleted_at' => $this->deleted_at,
];
}
}

View File

@@ -0,0 +1,114 @@
<?php
namespace App\Http\Controllers\Api\CardPin\Requests;
use App\Repos\System\Settings\Legal\PassportRepo;
use App\Repos\System\Settings\Location\RegionRepo;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class CardPinStoreRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<int, string>|string>
*/
public function rules(): array
{
return [
/**
* Card type id (https://online.tbbank.gov.tm/api/base-app-enums)
*/
'card_type_id' => ['required', 'integer', Rule::exists('card_types', 'id')],
/**
* Region (https://online.tbbank.gov.tm/api/base-app-enums)
*
* @example ag
*/
'region' => ['required', 'string', Rule::in(array_keys(RegionRepo::values()))],
/**
* Branch id (https://online.tbbank.gov.tm/api/branches)
*/
'branch_id' => ['required', 'integer', Rule::exists('branches', 'id')],
/**
* Customer name
*
* @example Mahmyt
*/
'customer_name' => ['required', 'string', 'max:255'],
/**
* Customer surname
*
* @example Allaberdiyev
*/
'customer_surname' => ['required', 'string', 'max:255'],
/**
* Customer patronic name
*
* @example Öwezowiç
*/
'customer_patronic_name' => ['nullable', 'string', 'max:255'],
/**
* Date of birth
*
* @example 10.10.2000
*/
'born_at' => ['required', 'before_or_equal:today'],
/**
* Passport serie
*
* @example I-AS
*/
'passport_serie' => ['required', 'string', Rule::in(PassportRepo::values())],
/**
* Passport number
*
* @example 100999
*/
'passport_id' => ['required', 'numeric', 'digits:6'],
/**
* Card number
*
* @example 9934 2312 2342 0249
*/
'card_number' => ['required', 'string'],
/**
* Phone number
*
* @example 65999990
*/
'phone' => ['required', 'integer', 'between:61000000, 71999999'],
/**
* Passport (sahypa 1)
*/
'passport_one' => ['required', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
/**
* Pasport (2-3-nji sahypa)
*/
'passport_two' => ['required', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
/**
* Pasport (8-9 sahypa)
*/
'passport_three' => ['required', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
/**
* Pasport (32-nji sahypa)
*/
'passport_four' => ['required', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
];
}
}