PHP code example of va / cutlet-helper

1. Go to this page and download the library: Download va/cutlet-helper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

va / cutlet-helper example snippets


integerToken($length = 5) // Generate integer token or code

stringToken($length = 16, $characters = '2345679acdefghjkmnpqrstuvwxyz') // Generate string token or code

digitsToEastern($number) // Covert a Weatern number(English) or digits to Eastern number(Persian or Arabic)

easternToDigits($number) // Covert a Eastern number(Persion, Arabic) to Eastern number(English)

isActive($key, $activeClassName = 'active') // Check the route name(string) or route names(array) is avtive or no for css classes

prepareInteger(input: string or integer) // removes `,` from integer (can be used in request for prices)

prepareSlug(slug, title, model) // generate clean slug from title and checks slug unique in specific model


// With Facade format:

CutletHelper::integerToken(length: 10);
CutletHelper::stringToken(length: 32, characters: '2345679acdefghjkmnpqrstuvwxyz');
CutletHelper::digitsToEastern(number: 1375);
CutletHelper::easternToDigits(number: ۱۳۷۵);
CutletHelper::isActive(key: ['posts.index', 'posts.create', 'posts.edit'], activeClassName: 'acive');
CutletHelper::prepareInteger(input: string or integer);
CutletHelper::prepareSlug(slug, title, model);


// Call a helper function:

integerToken(length: 10)
stringToken(length: 32, characters: '2345679acdefghjkmnpqrstuvwxyz');
digitsToEastern(number: 1375);
easternToDigits(number: ۱۲۳۴۵);
isActive(key: ['posts.index', 'posts.create', 'posts.edit'], activeClassName: 'acive');
prepareInteger(input: string or integer);
prepareSlug(slug, title, model);


return [
    'code' => 'e 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' => '

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'
];

return [
    'code' => ' [
    'code' => ['->validate([
    'code' => 'debit_card',
]);

// -- OR --

// You can add an optional parameter if you want to validate a card from a specific bank:
return [
    'code' => 'an (بانک مسکن)
 - postbank (پست بانک ایران)
 - ttbank (بانک توسعه تعاون)
 - enbank (بانک اقتصاد نوین)
 - parsian-bank (بانک پارسیان)
 - bpi (بانک پاسارگاد)
 - karafarinbank (بانک کارآفرین)
 - sb24 (بانک سامان)
 - sinabank (بانک سینا)
 - sbank (بانک سرمایه)
 - shahr-bank (بانک شهر)
 - bank-day (بانک دی)
 - bsi (بانک صادرات)
 - bankmellat (بانک ملت)
 - tejaratbank (بانک تجارت)
 - refah-bank (بانک رفاه)
 - ansarbank (بانک انصار)
 - mebank (بانک مهر اقتصاد)
*/

return [
    'code' => '
    'code' => ['->validate([
    'code' => 'postal_code',
]);

return [
    'code' => '
    'code' => ['->validate([
    'code' => 'shenase_meli',
]);

return [
    'mobile' => '   'mobile' => ['>validate([
    'mobile' => 'mobile',
]);

return [
    'username' => ' 'username' => ['lidate([
    'username' => 'username',
]);

return [
    'phone' => '    'phone' => ['>validate([
    'phone' => 'phone',
]);

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' => 'd,5'
];

// --OR--

return [
    // Without ignore for create user, 4 parameters
    'username' => ['

return [
    'code' => '
    'code' => ['->validate([
    'code' => 'persian_alphabetic',
]);

return [
    'code' => '
    'code' => ['->validate([
    'code' => 'persian_number',
]);

php artisan vendor:publish --tag=cutlet-helper