almas-exchange/lumen-sdk

交易所的lumen项目的微服务包

v1.1.8 2022-08-27 11:48 UTC

This package is auto-updated.

Last update: 2024-09-27 16:14:19 UTC


README

如何安装

composer require almas-exchange/lumen-sdk

需求

  • PHP >= 8.1
  • Lumen >= 9.0
在bootstrap/app.php中注册Service Provider以供Lumen使用
$app->register(Exchange\Providers\LumenSdkServiceProvider::class);
发布配置文件
php artisan vendor:publish --tag=lumen-sdk
Lumen设置路由前缀
// Change the route in app.php
$app->router->group([
    'namespace' => 'App\Http\Controllers',
    'prefix' => 'v1'
], function ($router) {
    require __DIR__.'/../routes/web.php';
});

包中存在的验证器

  • 国家代码(کد ملی)
  • IBAN(شماره شبا)
  • 信用卡(شماره کارت بانکی)
  • 邮政编码(کد پستی)
  • Shenase Meli(شناسه ملی)
  • 移动电话(موبایل)
  • 电话(تلفن ثابت)
  • 用户名(نام کاربری)
  • 唯一动态(تشخیص یکتایی دو ستونه)
  • 波斯字母(الفبای فارسی)
  • 波斯数字(اعداد فارسی)

验证器使用

national_code

用于验证伊朗国家代码的规则 (如何计算)

return [
    'code' => 'required|national_code'
];

For national_code with exeptions code or valid codes for foreign national codes
First step for use this parameters is migrate, php artisan migrate, and save your exeptions in this table 
but if you want to use another table you can set your table and column
return [
    'code' => 'required|national_code:national_code_exceptions' // This is default table that contains exeption codes
    -- OR -- 
    'code' => 'required|national_code:national_code_exceptions,code' // Second parameter is column of exeption table
];

-- OR --

return [
    'code' => ['required', 'national_code']
];

-- OR --

$validatedData = $request->validate([
    'code' => 'national_code',
]);

iban

用于验证IBAN(国际银行账户号码)的规则,在伊朗被称为Sheba。 (如何计算)

return [
    'account' => 'iban'
];

-- OR --

Add `false` optional parameter after `iban`, If IBAN doesn't begin with `IR`, so the validator will add `IR` as default to the account number:
return [
    'account' => 'iban:false'
];

-- OR --

If you want to validate non Iranian IBAN, add the 2 letters of country code after `false` optional parameter:
return [
    'account' => 'iban:false,DE'
];

credit_card

用于验证伊朗信用卡的规则。 (如何计算)

return [
    'code' => 'required|credit_card'
];

-- OR --

return [
    'code' => ['required', 'credit_card']
];

-- OR --

$validatedData = $request->validate([
    'code' => 'credit_card',
]);

-- OR --

You can add an optional parameter if you want to validate a card from a specific bank:
return [
    'code' => 'required|credit_card:bmi'
];

List of the bank codes:

 - bmi (بانک ملی)
 - banksepah (بانک سپه)
 - edbi (بانک توصعه صادرات)
 - bim (بانک صنعت و معدن)
 - bki (بانک کشاورزی)
 - bank-maskan (بانک مسکن)
 - postbank (پست بانک ایران)
 - ttbank (بانک توسعه تعاون)
 - enbank (بانک اقتصاد نوین)
 - parsian-bank (بانک پارسیان)
 - bpi (بانک پاسارگاد)
 - karafarinbank (بانک کارآفرین)
 - sb24 (بانک سامان)
 - sinabank (بانک سینا)
 - sbank (بانک سرمایه)
 - shahr-bank (بانک شهر)
 - bank-day (بانک دی)
 - bsi (بانک صادرات)
 - bankmellat (بانک ملت)
 - tejaratbank (بانک تجارت)
 - refah-bank (بانک رفاه)
 - ansarbank (بانک انصار)
 - mebank (بانک مهر اقتصاد)

zip_code

return [
    'code' => 'required|zip_code'
];

--OR--

return [
    'code' => ['required, 'zip_code']
];

--OR--

$validatedData = $request->validate([
    'code' => 'zip_code',
]);

shenase_meli

用于验证伊朗Shenase Meli的规则 (如何计算)

return [
    'code' => 'required|shenase_meli'
];

--OR--

return [
    'code' => ['required, 'shenase_meli']
];

--OR--

$validatedData = $request->validate([
    'code' => 'shenase_meli',
]);

mobile

return [
    'mobile' => 'required|mobile'
];

--OR--

return [
    'mobile' => ['required, 'mobile']
];

--OR--

$validatedData = $request->validate([
    'mobile' => 'mobile',
]);

用户名(有效字符:英语字母、数字和 _)

return [
    'username' => 'required|username'
];

--OR--

return [
    'username' => ['required, 'username']
];

--OR--

$validatedData = $request->validate([
    'username' => 'username',
]);

phone

return [
    'phone' => 'required|phone'
];

--OR--

return [
    'phone' => ['required, 'phone']
];

--OR--

$validatedData = $request->validate([
    'phone' => 'phone',
]);

unique_dynamic (table_name, target_column, extra_column, extra_column_value, ignore_column, ignore_column_value)

return [
    // Without ignore for create user, 4 parameters
    // If we want to check a username is unique in users table when type of this useranme equal student
    // If username = 'v.ashourzadeh' and type = 'student' you can't create username = 'v.ashourzadeh' but create username = 'v.ashourzadeh' if type = 'teacher'
    'username' => 'required|unique_dynamic:users,username,type,student'

    // With ignore for edit user, 6 parameters
    // If we want to check a username is unique in users table and ignore this for special id, for example id = 5
    // If username = 'v.ashourzadeh' and type = 'student' you can set username = 'v.ashourzadeh' when id = 5
    'username' => 'required|unique_dynamic:users,username,type,student,id,5'
];

--OR--

return [
    // Without ignore for create user, 4 parameters
    'username' => ['required, 'unique_dynamic:users,username,type,student']

    // With ignore for edit user, 6 parameter
    'username' => ['required, 'unique_dynamic:users,username,type,student,id,5']
];

--OR--

$validatedData = $request->validate([
    // Without ignore for create user, 4 parameters
    'username' => 'unique_dynamic:users,username,type,student',
    // With ignore for edit user, 6 parameter
    'username' => 'unique_dynamic:users,username,type,student,id,5',
]);

persian_alphabetic

return [
    'code' => 'required|persian_alphabetic'
];

--OR--

return [
    'code' => ['required, 'persian_alphabetic']
];

--OR--

$validatedData = $request->validate([
    'code' => 'persian_alphabetic',
]);

persian_number

return [
    'code' => 'required|persian_number'
];

--OR--

return [
    'code' => ['required, 'persian_number']
];

--OR--

$validatedData = $request->validate([
    'code' => 'persian_number',
]);