With the release of Laravel 11.13.0, we have some new additions to the helper functions.
Number::pairs
This function was contributed by hotmeteor
The `Number::pairs()` method allows you to divide a number into pairs based on the minimum and maximum values. This method can handle both integers and floating-point numbers.
$output = Number::pairs(25, 10);
// the first parameter is maximum and second parameter is window.
// [[1, 10], [11, 20], [21, 25]]
// the default offset is 1 but can be changed to 0
$output = Number::pairs(25, 10, 0);
// [[0, 10], [10, 20], [20, 25]]
$output = Number::pairs(10, 2.5, 0)
// [[0, 2.5], [2.5, 5.0], [5.0, 7.5], [7.5, 10.0]]
The use case of the function can be something like https://laravel.com/docs/11.x/queues#dispatching-batches
Here is the link to the PR
Str::chopStart and Str::chopEnd
These functions were contributed by timacdonald
Str::chopEnd('path/to/file.php', '.php');
// "path/to/file"
Str::chopStart('https://laravel.com', ['https://', 'http://']);
// laravel.com
These "chop" methods will only chop once when the given string exists.
Str::chopStart('https://www.laravel.com', ['https://', 'www.']);
// www.laravel.com
// www was not removed as https:// was found first.
Here is the link to the PR
Add Support for Extensions in Str::markdown
The support for commonmark extensions has been added to Str:markdown method by tnylea
public function parseMarkdownFromFile($file_location){
$markdown_contents = File::get($file_location);
$html = Str::markdown($markdown_contents, [], [
new AttributesExtension(),
new TaskListExtension(),
]);
return $html;
}
There is a video associated with the PR. I recommend watching the video for a better understanding of this update.
Check out what was new in laravel 11.12.0
v11.13.0
- [11.x] Add Support for Extensions in Str::markdown Method by @tnylea in #51907
- [11.x] Update config:show command by @seriquynh in #51902
- [11.x] Fix console prompt docblock by @seriquynh in #51913
- [11.x] Fix prohibit docblock by @seriquynh in #51916
- [11.x] Mark
$queue
as nullable by @timacdonald in #51912 - use
Macroable
trait on TokenGuard by @imanghafoori1 in #51922 - [11.x] Update Command::fail() dockblock and tests by @seriquynh in #51914
- Revert and add test by @jasonmccreary in #51924
- [11.x] Display view creation messages by @nshiro in #51925
- [11.x] Introduce
Str::chopStart
andStr::chopEnd
by @timacdonald in #51910 - feat: Add Number::pairs by @hotmeteor in #51904
- [11.x] Fixes escaping path via Process given commands as array by @crynobone in #51926
- [11.x] Make MultipleInstanceManager driver field customizable by @princejohnsantillan in #51905
- [11.x] Account for long strings on new Laravel error page by @shengslogar in #51880