Do you know Laravel have released version 9.48?

The Laravel team released 9.48 this week with conditional fragment helpers, HTTP configuration options for Symfony mailers, a new DB schema helper, and more:

Patrick Wan
3 min readJan 29

--

laravel-9.48

There have 7 new updates for Laravel version 9.48.

1. DB Schema helper to toggle foreign key constraints

2. New fragment helpers

3. Increment each query builder method

4. Drop an index when modifying a column

5. Configure custom HTTP client options for mailers

6. 402 status code exception view

7. HTTP client “notFound()” response helper

DB Schema helper to toggle foreign key constraints

Patrick Hesselberg contributed a withoutForeignKeyConstraints Schema method to conveniently disable foreign key constraints while managing a DB schema:

// Before
Schema::disableForeignKeyConstraints();
Schema::dropIfExists('table1');
Schema::dropIfExists('table2');
Schema::enableForeignKeyConstraints();

// After
Schema::withoutForeignKeyConstraints(function () {
Schema::dropIfExists('table1');
Schema::dropIfExists('table2');
});

New fragment helpers

Arko Elsenaar contributed a fragmentIf() method to return a fragment of a view conditionally. Sending a fragment is useful when sending a partial HTML view over the wire in XHR requests, for example:

// Before
if (request()->hasHeader('HX-Request')) {
return view('products.index')->fragment('products-list');
}

return view('products.index');

// After
return view('products.index')
->fragmentIf(
request()->hasHeader('HX-Request'),
'products-list'
);

Arko also contributed a fragments() method to return multiple fragments conveniently:

// Before using concatenation
view('welcome')->fragment('fragment1') …

--

--

Patrick Wan

My name’s Patrick. I’m a Software Developer, experience in Laravel, Vue Js, React Js, Livewire, Jquery, Codegniter, NPM, GIT. I have 5 years plus experience.