Download the PHP package djl997/blade-shortcuts without Composer
On this page you can find all versions of the php package djl997/blade-shortcuts. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download djl997/blade-shortcuts
More information about djl997/blade-shortcuts
Files in djl997/blade-shortcuts
Package blade-shortcuts
Short Description Blade Shortcuts is a library of handy Laravel Blade Directives.
License MIT
Informations about the package blade-shortcuts
Blade Shortcuts
Blade Shortcuts is a library of clever Blade Directives as listed below. The goal is to have less repetitive (base) logic in your Blade Views, overall shorter code and better readability.
Requirements
Blade Shortcuts requires PHP 8+ and Laravel 6+.
Installation
You can install the package via composer:
Usage
After installation, all directives should be usable immediately. If something goes wrong at first use or after an update, php artisan view:clear
should clear the issue.
Contents
- App Name
- Arrays
- Boolean
- Config
- Dates
- date, datetime, time, year, month, day
- dayOf
- dayOfWeek
- dayOfMonth
- dayOfYear
- cascades
- cascadeFromMinutes
- cascadeFromHours
- cascadeFromDays
- cascadeFromWeeks
- cascadeFromMonths
- Filesizes
- Fluent Strings
- Money
- Nl2br
- Not empty
- Not isset
- Percentage
App Name
Boolean
Config
Dates
Automatically translate dates in the correct localized format (currently only EN, NL, DE, ES supported).
Other options:
If the time difference is more than 23 hours, ‘dateOrDiff’ will automatically show the date in a localized format instead of ‘x time ago’ or ‘in x time’. You can adjust this threshold in the config file:
php artisan vendor:publish --tag=blade-shortcuts-config
.
Try shortcuts for datetime, time, year, month or day (also in the correct localized format):
You even can add a custom date to datetime, time, year, month or day, for example:
Day of Week, Day of Month, Day of Year
In some cases you need the x day of week, month or year.
Or generate it based on a value:
Carbon Cascades
If you want to display a certain amount of time in human readable format, try out the new cascade directives. For example, convert 125 minutes to a readable format:
Change the time unit
If you set the time unit (2nd item in the array), the cascade will cascade max to the given unit. In the example below, we have 1530 minutes, divided into hours of 60 minutes:
CarbonInterval
The example above also means you can tweak the CarbonInterval. Suppose you have a project that requires 125 hours of work and you can allocate 30 hours per day for it. How many days will it take to complete the project? We use the @cascadeFromHours
directive to calculate this value:
Filesize
nl2br
How to display input from a textarea
in a read-only situation? Maybe you use {!! $comment !!}
to get unexcaped data. In this way, you loose the XSS prevention, so maybe you sacrifice the newlines if the risk is too high. Now, that is no longer necessary: use the @nl2br
directive.
Not Empty, inverse of @empty
Not set, inverse of @isset
Percentages
Simple Money
Helpers
Arrays
Find all available methods in Laravel Docs.
Fluent strings
Find all available methods in Laravel Docs.
Publish config
Changelog
Please see GitHubs releases section for more information on what has changed recently.
Contributing
Contributions are welcome.
License
The MIT License (MIT). Please see License File for more information.
All versions of blade-shortcuts with dependencies
nesbot/carbon Version ^2.31|^3.0
laravel/framework Version ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0