Computers and TechnologyWeb Development

Advance Features Of Laravel 8.61

Laravel is one of the popular frameworks or can be said as a platform use widely among developers. They keep on releasing their new version on and off and the recent one was the release of Laravel 8. The laravel development company the customer’s experience by increasing the functionalities in their web and mobile applications. They have chosen the Laravel platform.
With the new releases, Laravel keeps on adding new features. so, companies prefer to hire a developer as they will be able to understand the utility of that feature. How it will be applied successfully while developing the application.
Now let’s discuss what are the new add on and how is it contributing to enhance the look and feel of the applications. Companies Hire Full Time Developers for a better understanding of the platforms.

Let’s look into what are the new Laravel features


1)Delete Or Fail Model Method

Laravel includes ORM , Object Relational Mapper (ORM) which is call by name Eloquent. this is the one which makes it easy to interact with the complete database. Laravel 8.61 release recently, and they are introducing delete or fail () model method which is a value or fail model method. It also asserts if the model exists in a test and accordingly the latest changes in the v8.x branch.
When one is using Eloquent, then each and every database has a corresponding Model. which is used to interact with that particular table. Delete or Fail Model Method helps in easy identification of the errors in the model column. Eloquent models allows one to insert, update, and accordingly delete the records from the table also. The Delete or Fail Method makes it less verbose than checking the return value of delete()
try {
} catch (Throwable $e) {

2)Assert If a Model Exists Test Method – Laravel

It refers to such a testing method that allows us to test if the Model exists in the database or not.
Example -@RVxLab contributing assertModelExists() testing method to test if a model is present in the database or not. One more model add by Taylor Otwell which is known by name- Assert Model Missing method.
$product = Productfind(1); 
$this-assertDatabaseHas(‘products’, [
    ‘id’ = $product-getKey(),

3)Value or Fail Model Method

@Italo contributed a valueOrFail() method that came up as a new feature of Laravel 8.60.
This feature actually helps to get the value of a single column. As a first result of all the queries or throws any kind of expectation.
Codes Before:
$votes = Userwhere(‘name’, ‘John’)-firstOrFail(‘votes’)-votes;
 Codes Now:
$votes = Userwhere(‘name’, ‘John’)-valueOrFail(‘votes’);
Allows Tests to Utilize the Null Logger
Tim MacDonald contributed a new update where tests can utilize the null logger. Check out Pull Request #38785 for further details on the given situation and updates made.

4)Better Syntax for Event Listening

In the previous version of the Laravel, while creating a closure-based event listener there was cumbersome syntax. For example:
protected $listen = [
    ‘App\Events\SomeEvent’ => [
But now it will  be as below without any repetition:
Event::listen(SomeEvent::class, function(SomeEvent $event) {
Event::listen(function (SomeEvent $event) {

5)Provision of back-off tries improvised

Earlier it used to be as below:
But now, by using a simple declaration there is exponential increase in the backoff tries like as below:
public function backoff()
     return [1, 5];

6)New Way to declare custom exceptions

Earlier report and render methods were used but now the below method can be used:
$this->reportable(function (AppException $e) {
$this->renderable(function (AppException $e) => … );

7)Create a Policy While Creating a Model

Tim Fevens developed a –policy flag, which is also include with the –all flag as well.
php artisan makemodel –policy Post

8)New way to re-write the factories

Here all the functions can be done relate to data,
For example.
// new  definition function
public function definition()
    return [
        ‘name’ => …blah blah
 // same
// custom functions
// which is:
public function withStatus()
    return $this->state(fn ($attributes) =>
    [‘status’ => ”];
//relationships of all kinds can be used in factory

9)Improvised Rate Limiting

New façade of global rate limiting is released,
[‘throttle:global’], [‘throttle:nested’],
// in configure functions

10) Job Batching

After the release of the latest version, Job Batching was introduce. Now,  all the jobs which can be triggered at one time can be queued and then it will be called back after the entire batch is completed. Even the failed items can be called back without interruption. Finally, real-time progress can be easily noticed. Bus::batch([
     new BatchedJob,
 ])->then(function (Batch $batch) {
        info(‘All Jobs completed Successfully’);
        info(‘First Batch job failure detected’);
        info(‘The batch has finished executing’);

11)New Catch method introduced for anonymous queue function

Initially the anonymous queue function went next to fail jobs but now there is provision that it can be called back easily.
Route::get(‘/queue-catch’, function(){
    dispatch(function() {
        throw new Exception(‘Something went wrong…’);
    })->catch(function (Throwable $e) {
        info(‘Caught exception’);
    return ‘Dispatched’;

12)Magic Prefixes in Namespaces have been removed

Route::get(‘/foo’, ‘FooController@index’)
Earlier, time when FooController was declare as well as. Behind the scenes App\Http\Controlllers\FooController was added by the RouteServiceProvider using this function:
protected function mapWebRoutes()
But now, the property of Namespace is trashed by default, so that if someone writes:
Route::get(‘/foo’, ‘\App\Http\Controlllers\FooController@index’) It won’t let magic prefixes be added.

13)Queuable anonymous event listeners

Further, model events can be queued in Models.
//in Foo Model Class
protected static function booting()
    static::created(queuable(function (Foo $foo){
        info(‘Queued: ‘ $foo->name);

14) Secret Maintenance mode is Introduce

Earlier IP whitelisting was difficult, now the route can access secretly. When the server is down during the maintenance mode, the mentioned command helps to access the application and routes. And it will be valid for several hours even during maintenance mode.
However, there are different options are available in the artisan down command like redirect, render, status. and secret to ensure more grip and control over it.
artisan down —secret=laracon-2020

15)Squash migration

The code will be – artisan schema:dump
This facilitates generating the complete existing migration into a schema file. In such a case if any new migration is made run using the above command, then the same command can be made run again.

16)Time Testing Helpers

During testing, one may need to modify occasionally the time returned by the helpers like now or Illuminate\Support\Carbon::now(),
public function testTimeCanBeManipulated()
    // Travel into the future…
    // Travel into the past…
    // Travel to an explicit time…
    // Return back to the present time…


Moreover, The above points state what new features have been add in the new version of Laravel. These new features enable the developers to provide more functionalities on the applications. The LarconOnline refers to the online platform where the details of the new updates of Laravel are shown from time to time. Laravel makes an effort to ease the common tasks of the developers.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button