Download the PHP package axn/tool-kit-for-laravel without Composer
On this page you can find all versions of the php package axn/tool-kit-for-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download axn/tool-kit-for-laravel
More information about axn/tool-kit-for-laravel
Files in axn/tool-kit-for-laravel
Package tool-kit-for-laravel
Short Description Includes a set of useful tools for the Laravel framework.
License MIT
Homepage https://github.com/AXN-Informatique/laravel-extension
Informations about the package tool-kit-for-laravel
Tool Kit for Laravel (formerly "Laravel extension")
Includes a set of useful tools for the Laravel framework.
- Installation
- Helpers
- app_env_enum()
- app_env_name()
- carbon()
- collect_models()
- str_html()
- linebreaks()
- nl_to_p()
- nl_to_br()
- number_formated()
- number_fr()
- compute_dec_to_time()
- convert_dec_to_time()
- human_readable_bytes_size()
- trans_ucfirst()
- is_valid_model()
- semver_to_id()
- Blade directives
- @nltop()
- @nltobr()
- Components
- Add an indicator for a required field
- Enums
- Environment application
- Civilities
Installation
With Composer :
To use some of these tools you must have correctly installed the package forxer/generic-term-translations-for-laravel already prerequisite by this package (therefore present).
Use the locales publisher of Laravel Lang to add/update/reset or remove translations:
- If you have never used Laravel Lang: add locales
- If you are already using Laravel Lang: just update the locales
Helpers
app_env_enum()
Returns a standardized enumeration of the application environment based on the "app.env" configuration variable. This helper uses the AppEnv
enumeration.
Note that the return value is static, it always returns the first value in the same request. If the environment is modified at runtime, this will not be taken into account (but who does that?).
For more details please see the chapter on AppEnv enumeration.
app_env_name()
Returns a standardized name of the application environment based on the "app.env" configuration variable. This helper uses the AppEnv
enumeration.
Note that the return value is static, it always returns the first value in the same request. If the environment is modified at runtime, this will not be taken into account (but who does that?).
For more details please see the chapter on AppEnv enumeration.
carbon()
Create a Carbon instance from a date string, a DateTime instance or a timestamp.
Here are some examples.
Using Carbon:
Equivalents using helper:
collect_models()
Create a collection of Eloquent models.
str_html()
Create an Illuminate\Support\HtmlString
instance.
linebreaks()
Convert all line-endings to UNIX format.
Replace "\r\n"
and "\r"
by "\n"
nl_to_p()
Convert new lines into HTML paragraphs <p>
.
nl_to_br()
Alias of native PHP function nl2br()
.
number_formated()
Returns a number in current language format.
number_fr()
Returns a number in french format.
compute_dec_to_time()
Decimal to time calculation, return an array with hours, minutes and seconds.
convert_dec_to_time()
Decimal to time conversion. Output can be changed with sprintf
format.
human_readable_bytes_size()
Convert a bytes size into a human readable localized size.
mime_type_to_fa5_class()
Return a font awesome file icon class for specific MIME Type.
trans_ucfirst()
Translate the given message with first character uppercase.
is_valid_model()
Indicates whether the model class is instantiable and is an instance of Illuminate\Database\Eloquent\Model
.
semver_to_id()
Transforms a semver version number into a numeric identifier. Please note: does not take into account "pre-releases" (RC, beta, etc.)
This is useful for optimizing comparisons, searches and sorting in a database on numeric rather than text columns.
Blade directives
@nltop()
Convert new lines into HTML paragraphs <p>
.
Displays:
@nltobr()
Convert new lines into HTML <br>
Displays:
Components
Add an indicator for a required field
To display a required field marker (e.g. in a label tag):
Displays:
You can change the default symbol "*" (an asterisk) by the marker symbol of your choice:
You can style it for example like this:
In your forms you can indicate the required fields for example in this way:
Enums
Environment application
This package provides a utility enum AppEnv
. This allows to standardize environment names.
Indeed, for example, some projects uniformly have the environment "prod" and "production"; or even "preprod" and "pre-production", worse: "pre-prod".
Creating an instance of the enumeration from a character string:
Find the standardized name from a string:
Testing the environment type:
Reverse methods are available:
Retrieving environment values defined in the enum:
Civilities
An enumeration to handle civilities is available with Axn\ToolKit\Enums\Civilities
@todo: need to document this
All versions of tool-kit-for-laravel with dependencies
composer/semver Version ^3.0.0
forxer/generic-term-translations-for-laravel Version ^1.8
laravel/framework Version ^10.0 || ^11.0