laravel 5.3 is planned to be released in June 2016 , this article is a rundown of the considerable number of things you can expect in this release . currently laravel 5.3 is in development .
Route::controller is no longer available in 5.3, the reasons for that change are stated in Pull Request #10777, here’s part of it:
This method has quite a lot of issues and also makes routes definitions confusing as they are not directly referenced in routes file. This sometimes may lead to unexpected route definitions (e. g. if method like getFilesystem is added to parent or trait – developer mistake, but may be unnoticed).
It’s more likely that this method will be available as a package, so it’s up to you to decide if you’re going to keep using it or switch to using explicit route definitions, however if you decided to switch it’s better to start now.
As of 5.3, the query builder
get() method will return an
Illuminate\Support\Collection instead of an array. The Pros of such change, as listed by the PR creator, are:
So if you’re expecting an array out of
DB::get() anywhere in your application or tests you’ll need to update your calls to be
Str::equalsare removed in favour of the native PHP methods
lists()method is also removed from ELoquent Builder, Query Builder, and Collections. You may use the
array_build()helper is also removed from the framework as it’s no longer used anywhere in the core.
withHidden()method is removed in favour of
makeVisible(), same goes for Eloquent Collection’s
withHidden(). So in order for you to make certain fields visible after defining them as hidden using the Model’s
hiddenproperty, you’ll need to use
Collection::whereLoose()method was removed since
Collection::where()now supports operators.
The new method will throw a
ValidationException if the Validations fails, here are the different ways you can use this method:
Using the Validation factory:
$validator = Validator::make($data, $rules); $validator->validate();
Or on the Validator directly:
Or using the helper method:
In laravel 5.3 you’re able to filter a collection using
where() via operators, and also a major change is that the method performs a loose comparison when not given any operators:
$collection = collect([['score' => '3'], ['score' => 3]]); // Loose comparison by default $collection->where('score', 3); // returns [['score' => '3'], ['score' => 3]] $collection->where('score', '=', 3); $collection->where('score', '==', 3); // returns [['score' => '3'], ['score' => 3]] $collection->where('score', '===', 3); // returns [['score' => 3]]
Here’s a list of all the operators you can use:
With these operators available, the
whereLoose() method was removed from the collection class as it’s not needed anymore.
With this change you’ll be able to do something like:
$user = User::firstOrCreate( ['github_id', $githubUser->id], ['avatar' => $githubUser->avatar] );
In case a user with the given
github_id was found it’ll be returned, if not a new user will be created with the given
read full article at themsaid.com
You may be surprised at how many of the same skills are involved! Let’s get…
Introduction As more and more people are using online services nowadays, most of the business…
Small businesses need all the advertisements they can get. Traditional avenues for advertising, such as…
Freelancing and working from home was long considered idyllic by many, but the global pandemic…