laravel and php tools

v1.3.2 2025-05-06 05:20 UTC

This package is auto-updated.

Last update: 2025-06-06 05:29:41 UTC


README

Total Downloads Latest Stable Version License

Tools

This package include library classes with specific static function tools.

List of content

Install

run this command:

composer require erfankatebsaber/tools

Next, add ErfanKatebSaber\tools\ToolsProvider::class into config\app.php file:

'providers' => [
    // other providers
    ErfanKatebSaber\tools\ToolsProvider::class
]

Then, run this command to create config file:

php artisan vendor:publish --tag=tools

Classes

  • StrTools: This class include specific static functions to make easly string editing.
  • AuthTools: This class include specific static functions to make easily use laravel auth.

Config

After installing this package, the config file created into this path:

config/tools.php

This file content like this:

<?php

return [

    'auth'=>[
        'login_routes' => [
            /**
             * guard name => route name
             */
            'web' => 'login',

            /**
             * if not found guard route, we redirect the user after logout to this route name
             */
            'default' => 'login',
        ],
        'auth_guard_name' => [
            'web' => 'user'
        ]
    ],
    'str' => [
        'persian_numbers' => [
            '۰' => '0',
            '۱' => '1',
            '۲' => '2',
            '۳' => '3',
            '۴' => '4',
            '۵' => '5',
            '۶' => '6',
            '۷' => '7',
            '۸' => '8',
            '۹' => '9',
        ],
        'wrong_numbers' => [
            'º' => '0',
            '¹' => '1',
            '²' => '2',
            '³' => '3',
            '' => '4',
            '' => '5',
            '' => '6',
            '' => '7',
            '' => '8',
            '' => '9'
        ],
        'empty_chars' => [
            '', // half space
        ],
        'words_to_change' => [
            // from => to
            'ي' => 'ی',
            'ة' => 'ه',
            'ك' => 'ک',
        ]
    ]

];

Parts Descriptions

auth

login_routes

You can define specific route for each guard type to redirect after logout by AuthTools::Logout().

auth_guard_name

You can define name for each guard type to display this via StrTools::GetGuardName('YOUR_GUARD_NAME').

In default config option, the result of this StrTools::GetGuardName('web'), is user.

str

persian_numbers

Persian numbers to replace by StrTools::ConvertPersianNumbers or StrTools::RepairNumber functions.

Also, the StrTools::JustNumber function use this config.

wrong_numbers

Replace wrong numbers by StrTools::RepairNumber function.

Also, the StrTools::JustNumber function use this config.

empty_chars

Detect empty chars by StrTools::IsEmptyString function. One of uses of this function is to prevent deception by users (like username by uesr).

words_to_change

Replace words by StrTools::AutoChangeWord function. One of uses of this function is prevent confusing users by store or show chars that have same appearance.

Licence

Tis package is open-sourced library licensed under the MIT license.