Share your code editable and funny templates.

What's New In Laravel - The Php Framework For Web Artisans

Published on February 18, 2024 by

What's New in Laravel - The PHP Framework For Web Artisans

Let's discuss the most recent changes to the framework. I have some really awesome new features. Allow me to demonstrate.

Base64 String Methods

First we have two new methods for a string helper to Str::toBase64() and Str::fromBase64() and you guessed it already, it's about base64 encoding and decoding. We can now do it fluently through the string helper.

<?php
use Illuminate\Support\Str;
 
$encoded = Str::toBase64('my-string');
$decoded = Str::fromBase64($string);

Array Take

Next we got a new method on the array helper. I'll show you.

<?php
use Illuminate\Support\Arr;
 
$numbers = [1, 2, 3, 4, 5, 6];
return Arr::take($numbers, -3);
// [4,5,6]

Collection Select

Next we got a new method on Collection select(). I'll show you

<?php
use Illuminate\Support\Collection;
 
$users = collect([
[
"name" => "Hari Uprety",
"email" => "[email protected]",
"role" => "developer"
],
[
"name" => "Dinesh Uprety",
"email" => "[email protected]",
"role" => "developer"
],
[
"name" => "Manohar Devkota",
"email" => "[email protected]",
"role" => "developer"
]
]);
 
$users->select('name', 'email'); // only return selected keys value
 
/*
[
[
"name" => "Hari Uprety",
"email" => "[email protected]",
],
[
"name" => "Dinesh Uprety",
"email" => "[email protected]",
],
[
"name" => "Manohar Devkota",
"email" => "[email protected]",
]
]
*/
Dinesh Uprety

Senior Software Engineer • Writer @ Laranepal • PHP, Laravel, Livewire, TailwindCSS & VueJS • CEO @ Laranepal & Founder @ laracodesnap

Filed in:

Discussion

Login or register to comment or ask questions

No comments yet

Be the first to share your thoughts or ask a question.

Join the conversation

Sign in to share your thoughts with the community.

SPONSORED
Codesnap

Codesnap

Share your code editable and funny templates.