Loading image

Blogs / Programming

Laravel 10.35 Released

Laravel 10.35 Released

  • showkat ali
  • 0 Comments
  • 3933 View

 

Laravel 10.35 Released: New Features and Updates

The Laravel team released v10.35 with a Blade @use directive, a number abbreviation helper, the ability to generate a secret with artisan down, and more. Here is a bit more info about the new features introduced this week:

Here's a breakdown of the new features in Laravel 10.35:

 

1. Blade @use Directive:

This directive allows you to import PHP classes directly into your Blade templates without using raw PHP tags. This makes your code cleaner and more readable.

Benefits:

  • Improved Readability: You can avoid writing raw PHP code within your Blade templates, making them more readable and maintainable.
  • Reduced Clutter: You can import multiple classes at once, reducing the need for repeated @php blocks.
  • Centralized Organization: You can organize your code by importing classes from separate files, promoting better code structure.

Example:

 

{-- Before --}}
@php
use \App\Enums\WidgetStatusEnum as Status;
@endphp
 
{{-- After --}}
@use('App\Enums\WidgetStatusEnum', 'Status')
@use('App\Models\Bar')
 
{{ Status::Foo }}
{{ Bar::first() }}

2. Number Abbreviation:

The Number::abbreviate() method converts large numbers into human-readable formats, like "1M" for 1 million. This improves the display and readability of large numbers in your application.

Benefits:

  • Concise Representation: Large numbers are displayed in a compact and easily understandable format.
  • Enhanced User Experience: Users can easily grasp the magnitude of large numbers without needing to decipher complicated formats.
  • Improved Accessibility: Abbreviated numbers are easier to read for users with visual impairments.

Example:

Number::abbreviate(1_000_000); // "1M"
Number::abbreviate(100_001);   // "100K"
Number::abbreviate(99_999);    // "100K"
Number::abbreviate(99_499);    // "99K"

3. Secret Generation for Artisan Down:

The artisan down command now accepts the --with-secret option to automatically generate a secret key for bypassing maintenance mode. This simplifies the process and avoids the need to manually define a secret.

Benefits:

  • Simplified Maintenance: You can quickly enable maintenance mode without needing to define a secret key.
  • Enhanced Security: Generated secrets are more secure than manually defined ones, reducing the risk of unauthorized access.
  • Convenience: It saves time and effort compared to manually defining and managing secrets.

Example:

php artisan down --with-secret

4. Conditional Assertions in AssertableJson:

The AssertableJson class now supports the Conditionable trait, allowing you to write conditional assertions within a single chain of assertions. This improves the clarity and conciseness of your test code.

Benefits:

  • More Readable Tests: You can write conditional assertions without needing nested blocks, making your tests more readable and easier to follow.
  • Reduced Code Duplication: You can avoid repeating the same assertion logic within multiple conditions.
  • Improved Test Maintenance: Maintaining your test code becomes easier with a single assertion chain for different conditions.

Example:

// Before
$response->assertJson(function (AssertableJson $json) use ($condition) {
    $json->has('data');
 
    if ($condition) {
        $json->has('meta');
    }
 
   $json->etc();
});
 
// After
$response
    ->assertJson(fn (AssertableJson $json) => $json->has('data'))
    ->when($condition, fn (AssertableJson $json) => $json->has('meta'))
    // ...
;

Additional Resources:

 

 

 

 

 

 

 

 

  • Programming
showkat ali Author

showkat ali

Greetings, I'm a passionate full-stack developer and entrepreneur. I specialize in PHP, Laravel, React.js, Node.js, JavaScript, and Python. I own interviewsolutionshub.com, where I share tech tutorials, tips, and interview questions. I'm a firm believer in hard work and consistency. Welcome to interviewsolutionshub.com, your source for tech insights and career guidance.

0 Comments

Post Comment

Recent Blogs

Recent posts form our Blog

An Innovative Method to Building Online Urdu Corpus (اردو کارپس)

An Innovative Method to Building Online Urdu Corpus (اردو کارپس)

Nasir Hussain
/
English

Read More
How to Use Summernote Editor in Laravel 10?

How to Use Summernote Editor in Laravel 10?

showkat ali
/
Programming

Read More
Cybersecurity: A Critical Necessity in the Digital Age

Cybersecurity: A Critical Necessity in the Digital Age

fatima qandeel
/
Technology

Read More
How to Integrate TinyMCE in Laravel | Latest 2024

How to Integrate TinyMCE in Laravel | Latest 2024

showkat ali
/
Programming

Read More
How to Use Quill Rich Text Editor Laravel 10: A Comprehensive Guide

How to Use Quill Rich Text Editor Laravel 10: A Comprehensive Guide

showkat ali
/
Programming

Read More
Five Steps Sample Lesson Plan for English Grade 5th, 6th, 7th 8th, 9th, and 10th

Five Steps Sample Lesson Plan for English Grade 5th, 6th, 7th 8th, 9th, and 10th

Nasir Hussain
/
English

Read More