wip
This commit is contained in:
@@ -111,7 +111,7 @@ class CardBalanceController extends Controller
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'data' => $response
|
||||
'data' => $response,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
142
app/Http/Controllers/Api/CardPin/CardPinController.php
Normal file
142
app/Http/Controllers/Api/CardPin/CardPinController.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\CardPin;
|
||||
|
||||
use App\Http\Controllers\Api\CardPin\Requests\CardPinIndexResource;
|
||||
use App\Http\Controllers\Api\CardPin\Requests\CardPinStoreRequest;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Order\Card\CardPin\CardPin;
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use Dedoc\Scramble\Attributes\Group;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
#[Group('Sargytlar - Kart - Kart pin bukjalar')]
|
||||
class CardPinController extends Controller
|
||||
{
|
||||
/**
|
||||
* LIST*
|
||||
*/
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
return response()->json(CardPinIndexResource::collection(
|
||||
CardPin::query()
|
||||
->with('branch', 'cardType')
|
||||
->where('user_id', auth()->id())
|
||||
->get()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* SAVE*
|
||||
*/
|
||||
public function store(CardPinStoreRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->validated();
|
||||
|
||||
CardPin::forceCreate([
|
||||
...$data,
|
||||
...[
|
||||
'status' => OrderRepo::PENDING,
|
||||
'user_id' => auth()->id(),
|
||||
],
|
||||
...$this->uploadedFiles($request),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully created'),
|
||||
], 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload files
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function uploadedFiles(Request $request): array
|
||||
{
|
||||
$files = [];
|
||||
|
||||
foreach (['passport_one', 'passport_two', 'passport_three', 'passport_four'] as $field) {
|
||||
if ($request->hasFile($field)) {
|
||||
$files[$field] = Str::after($request->file($field)->store('public'), 'public/');
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* SHOW*
|
||||
*
|
||||
* ID ugradyp alyan route -da.
|
||||
*/
|
||||
public function show(CardPin $order): JsonResponse
|
||||
{
|
||||
if ($order->user_id != auth()->id()) {
|
||||
return response()->json(status: 403);
|
||||
}
|
||||
|
||||
return response()->json(new CardPinIndexResource($order));
|
||||
}
|
||||
|
||||
// /**
|
||||
// * UPDATE*
|
||||
// *
|
||||
// * ID ugradyp `route`-da update edip bilyan. Base App Enum-lardan peydalan. Panelkadan gor.
|
||||
// */
|
||||
// public function update(Request $request, CardBalance $order): JsonResponse
|
||||
// {
|
||||
// $data = $request->validate([
|
||||
// /**
|
||||
// * @example I-AS
|
||||
// */
|
||||
// 'passport_serie' => ['sometimes', Rule::in(array_keys(PassportRepo::values()))],
|
||||
|
||||
// /**
|
||||
// * @example 379514
|
||||
// */
|
||||
// 'passport_id' => ['sometimes', 'numeric', 'digits:6'],
|
||||
|
||||
// /**
|
||||
// * @example 9934612100000243
|
||||
// */
|
||||
// 'card_number' => ['sometimes', 'digits:16'],
|
||||
|
||||
// /**
|
||||
// * @example 12
|
||||
// */
|
||||
// 'card_month' => ['sometimes', Rule::in(array_keys(DateHelperRepository::staticNumberMonths()))],
|
||||
|
||||
// /**
|
||||
// * @example 2049
|
||||
// */
|
||||
// 'card_year' => ['sometimes', Rule::in(array_keys(DateHelperRepository::staticNumberYears()))],
|
||||
// ]);
|
||||
|
||||
// Model::unguarded(function () use ($order, $data) {
|
||||
// $order->update($data);
|
||||
// });
|
||||
|
||||
// return response()->json([
|
||||
// 'message' => __('Successfully updated'),
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * DELETE*
|
||||
// */
|
||||
// public function destroy(CardBalance $order): JsonResponse
|
||||
// {
|
||||
// if ($order->user_id != auth()->id()) {
|
||||
// return response()->json(status: 403);
|
||||
// }
|
||||
|
||||
// $order->delete();
|
||||
|
||||
// return response()->json([
|
||||
// 'message' => __('Successfully deleted'),
|
||||
// ]);
|
||||
// }
|
||||
}
|
||||
@@ -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,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,31 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property null|string $unique_id
|
||||
* @property int $card_type_id
|
||||
* @property string $card_number
|
||||
* @property string $region
|
||||
* @property int $branch_id
|
||||
* @property string $customer_name
|
||||
* @property string $customer_surname
|
||||
* @property null|string $customer_patronic_name
|
||||
* @property null|string $born_at
|
||||
* @property null|string $phone
|
||||
* @property string $passport_serie
|
||||
* @property string $passport_id
|
||||
* @property null|string $status
|
||||
* @property null|string $passport_one
|
||||
* @property null|string $passport_two
|
||||
* @property null|string $passport_three
|
||||
* @property null|string $passport_four
|
||||
* @property null|string $notes
|
||||
* @property int $user_id
|
||||
* @property null|string $created_at
|
||||
* @property null|string $updated_at
|
||||
* @property null|string $deleted_at
|
||||
*/
|
||||
class CardPin extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
**completed**
|
||||
**cancelled**
|
||||
|
||||
Schema::getColumnListing('loan_paid_off_letter_orders')
|
||||
Schema::getColumnListing('card_pins')
|
||||
|
||||
$a = collect(Schema::getColumns('loan_paid_off_letter_orders'))->map(fn ($column) => [
|
||||
$a = collect(Schema::getColumns('card_pins'))->map(fn ($column) => [
|
||||
'name' => $column['name'],
|
||||
'type' => ($column['nullable'] ? 'null|' : '') . dbTypeToPhp($column['type']),
|
||||
])->pluck('type', 'name')
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
use App\Http\Controllers\AlertController;
|
||||
use App\Http\Controllers\Api\CardBalance\CardBalanceController;
|
||||
use App\Http\Controllers\Api\CardOrder\CardOrderController;
|
||||
use App\Http\Controllers\Api\CardPin\CardPinController;
|
||||
use App\Http\Controllers\Api\CardRequisite\CardRequisiteController;
|
||||
use App\Http\Controllers\Api\CardTransaction\CardTransactionsController;
|
||||
use App\Http\Controllers\Api\FetchLoanHistoryController;
|
||||
@@ -125,4 +126,10 @@ Route::middleware(['auth:sanctum', 'not_banned'])->group(function () {
|
||||
Route::post('card-balances/{order}', [CardBalanceController::class, 'update']);
|
||||
Route::delete('card-balances/{order}', [CardBalanceController::class, 'destroy']);
|
||||
|
||||
// Card pin-order...
|
||||
Route::get('card-pin-order', [CardPinController::class, 'index']);
|
||||
Route::get('card-pin-order/{order}', [CardPinController::class, 'show']);
|
||||
Route::post('card-pin-order', [CardPinController::class, 'store']);
|
||||
Route::post('card-pin-order/{order}', [CardPinController::class, 'update']);
|
||||
Route::delete('card-pin-order/{order}', [CardPinController::class, 'destroy']);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user