From b1a6d3954b6340d68c29e02097cf72f8374d0ae6 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 3 Sep 2019 16:18:06 +0200 Subject: [PATCH 1/8] Prepare master for 7.0 --- releases.md | 202 +----------------------------------- upgrade.md | 292 ++-------------------------------------------------- 2 files changed, 14 insertions(+), 480 deletions(-) diff --git a/releases.md b/releases.md index 0b5eb3450e1..5a196172dac 100644 --- a/releases.md +++ b/releases.md @@ -2,14 +2,14 @@ - [Versioning Scheme](#versioning-scheme) - [Support Policy](#support-policy) -- [Laravel 6.0](#laravel-6.0) +- [Laravel 7.0](#laravel-7.0) ## Versioning Scheme Laravel and its other first-party packages follow [Semantic Versioning](https://semver.org). Major framework releases are released every six months (February and August), while minor and patch releases may be released as often as every week. Minor and patch releases should **never** contain breaking changes. -When referencing the Laravel framework or its components from your application or package, you should always use a version constraint such as `^6.0`, since major releases of Laravel do include breaking changes. However, we strive to always ensure you may update to a new major release in one day or less. +When referencing the Laravel framework or its components from your application or package, you should always use a version constraint such as `^7.0`, since major releases of Laravel do include breaking changes. However, we strive to always ensure you may update to a new major release in one day or less. ## Support Policy @@ -24,199 +24,7 @@ For LTS releases, such as Laravel 6.0, bug fixes are provided for 2 years and se | 5.8 | February 26th, 2019 | August 26th, 2019 | February 26th, 2020 | | 6.0 (LTS) | September 3rd, 2019 | September 3rd, 2021 | September 3rd, 2022 | - -## Laravel 6.0 + +## Laravel 7.0 -Laravel 6.0 (LTS) continues the improvements made in Laravel 5.8 by introducing semantic versioning, compatibility with [Laravel Vapor](https://vapor.laravel.com), improved authorization responses, job middleware, lazy collections, sub-query improvements, the extraction of frontend scaffolding to the `laravel/ui` Composer package, and a variety of other bug fixes and usability improvements. - -### Semantic Versioning - -The Laravel framework (`laravel/framework`) package now follows the [semantic versioning](https://semver.org/) standard. This makes the framework consistent with the other first-party Laravel packages which already followed this versioning standard. The Laravel release cycle will remain unchanged. - -### Laravel Vapor Compatibility - -_Laravel Vapor was built by [Taylor Otwell](https://github.com/taylorotwell)_. - -Laravel 6.0 provides compatibility with [Laravel Vapor](https://vapor.laravel.com), an auto-scaling serverless deployment platform for Laravel. Vapor abstracts the complexity of managing Laravel applications on AWS Lambda, as well as interfacing those applications with SQS queues, databases, Redis clusters, networks, CloudFront CDN, and more. - -### Improved Exceptions Via Ignition - -Laravel 6.0 ships with [Ignition](https://github.com/facade/ignition), a new open source exception detail page created by Freek Van der Herten and Marcel Pociot. Ignition offers many benefits over previous releases, such as improved Blade error file and line number handling, runnable solutions for common problems, code editing, exception sharing, and an improved UX. - -### Improved Authorization Responses - -_Improved authorization responses were implemented by [Gary Green](https://github.com/garygreen)_. - -In previous releases of Laravel, it was difficult to retrieve and expose custom authorization messages to end users. This made it difficult to explain to end-users exactly why a particular request was denied. In Laravel 6.0, this is now much easier using authorization response messages and the new `Gate::inspect` method. For example, given the following policy method: - - /** - * Determine if the user can view the given flight. - * - * @param \App\User $user - * @param \App\Flight $flight - * @return mixed - */ - public function view(User $user, Flight $flight) - { - return $this->deny('Explanation of denial.'); - } - -The authorization policy's response and message may be easily retrieved using the `Gate::inspect` method: - - $response = Gate::inspect('view', $flight); - - if ($response->allowed()) { - // User is authorized to view the flight... - } - - if ($response->denied()) { - echo $response->message(); - } - -In addition, these custom messages will automatically be returned to your frontend when using helper methods such as `$this->authorize` or `Gate::authorize` from your routes or controllers. - -### Job Middleware - -_Job middleware were implemented by [Taylor Otwell](https://github.com/taylorotwell)_. - -Job middleware allow you wrap custom logic around the execution of queued jobs, reducing boilerplate in the jobs themselves. For example, in previous releases of Laravel, you may have wrapped the logic of a job's `handle` method within a rate-limited callback: - - /** - * Execute the job. - * - * @return void - */ - public function handle() - { - Redis::throttle('key')->block(0)->allow(1)->every(5)->then(function () { - info('Lock obtained...'); - - // Handle job... - }, function () { - // Could not obtain lock... - - return $this->release(5); - }); - } - -In Laravel 6.0, this logic may be extracted into a job middleware, allowing you to keep your job's `handle` method free of any rate limiting responsibilities: - - block(0)->allow(1)->every(5) - ->then(function () use ($job, $next) { - // Lock obtained... - - $next($job); - }, function () use ($job) { - // Could not obtain lock... - - $job->release(5); - }); - } - } - -After creating middleware, they may be attached to a job by returning them from the job's `middleware` method: - - use App\Jobs\Middleware\RateLimited; - - /** - * Get the middleware the job should pass through. - * - * @return array - */ - public function middleware() - { - return [new RateLimited]; - } - -### Lazy Collections - -_Lazy collections were implemented by [Joseph Silber](https://github.com/JosephSilber)_. - -Many developers already enjoy Laravel's powerful [Collection methods](https://laravel.com/docs/collections). To supplement the already powerful `Collection` class, Laravel 6.0 introduces a `LazyCollection`, which leverages PHP's [generators](https://www.php.net/manual/en/language.generators.overview.php) to allow you to work with very large datasets while keeping memory usage low. - -For example, imagine your application needs to process a multi-gigabyte log file while taking advantage of Laravel's collection methods to parse the logs. Instead of reading the entire file into memory at once, lazy collections may be used to keep only a small part of the file in memory at a given time: - - use App\LogEntry; - use Illuminate\Support\LazyCollection; - - LazyCollection::make(function () { - $handle = fopen('log.txt', 'r'); - - while (($line = fgets($handle)) !== false) { - yield $line; - } - }) - ->chunk(4) - ->map(function ($lines) { - return LogEntry::fromLines($lines); - }) - ->each(function (LogEntry $logEntry) { - // Process the log entry... - }); - -Or, imagine you need to iterate through 10,000 Eloquent models. When using traditional Laravel collections, all 10,000 Eloquent models must be loaded into memory at the same time: - - $users = App\User::all()->filter(function ($user) { - return $user->id > 500; - }); - -However, beginning in Laravel 6.0, the query builder's `cursor` method has been updated to return a `LazyCollection` instance. This allows you to still only run a single query against the database but also only keep one Eloquent model loaded in memory at a time. In this example, the `filter` callback is not executed until we actually iterate over each user individually, allowing for a drastic reduction in memory usage: - - $users = App\User::cursor()->filter(function ($user) { - return $user->id > 500; - }); - - foreach ($users as $user) { - echo $user->id; - } - -### Eloquent Subquery Enhancements - -_Eloquent subquery enhancements were implemented by [Jonathan Reinink](https://github.com/reinink)_. - -Laravel 6.0 introduces several new enhancements and improvements to database subquery support. For example, let's imagine that we have a table of flight `destinations` and a table of `flights` to destinations. The `flights` table contains an `arrived_at` column which indicates when the flight arrived at the destination. - -Using the new subquery select functionality in Laravel 6.0, we can select all of the `destinations` and the name of the flight that most recently arrived at that destination using a single query: - - return Destination::addSelect(['last_flight' => Flight::select('name') - ->whereColumn('destination_id', 'destinations.id') - ->orderBy('arrived_at', 'desc') - ->limit(1) - ])->get(); - -In addition, we can use new subquery features added to the query builder's `orderBy` function to sort all destinations based on when the last flight arrived at that destination. Again, this may be done while executing a single query against the database: - - return Destination::orderByDesc( - Flight::select('arrived_at') - ->whereColumn('destination_id', 'destinations.id') - ->orderBy('arrived_at', 'desc') - ->limit(1) - )->get(); - -### Laravel UI - -The frontend scaffolding typically provided with previous releases of Laravel has been extracted into a `laravel/ui` Composer package. This allows the first-party UI scaffolding to be developed and versioned separately from the primary framework. As a result of this change, no Bootstrap or Vue code is present in default framework scaffolding, and the `make:auth` command has been extracted from the framework as well. - -In order to restore the traditional Vue / Bootstrap scaffolding present in previous releases of Laravel, you may install the `laravel/ui` package and use the `ui` Artisan command to install the frontend scaffolding: - - composer require laravel/ui - - php artisan ui vue --auth +Release notes will be placed here. diff --git a/upgrade.md b/upgrade.md index 6eb7718bdc8..6b0b0c55630 100644 --- a/upgrade.md +++ b/upgrade.md @@ -1,307 +1,33 @@ # Upgrade Guide -- [Upgrading To 6.0 From 5.8](#upgrade-6.0) +- [Upgrading To 7.0 From 6.0](#upgrade-7.0) ## High Impact Changes
-- [Authorized Resources & `viewAny`](#authorized-resources) -- [String & Array Helpers](#helpers) +- ...
## Medium Impact Changes
-- [Authentication `RegisterController`](#the-register-controller) -- [Carbon 1.x No Longer Supported](#carbon-support) -- [Database `Capsule::table` Method](#capsule-table) -- [Eloquent Arrayable & `toArray`](#eloquent-to-array) -- [Eloquent `BelongsTo::update` Method](#belongs-to-update) -- [Eloquent Primary Key Types](#eloquent-primary-key-type) -- [Localization `Lang::trans` and `Lang::transChoice` Methods](#trans-and-trans-choice) -- [Localization `Lang::getFromJson` Method](#get-from-json) -- [Queue Retry Limit](#queue-retry-limit) -- [Resend Email Verification Route](#email-verification-route) -- [The `Input` Facade](#the-input-facade) +- ...
- -## Upgrading To 6.0 From 5.8 + +## Upgrading To 7.0 From 6.0 -#### Estimated Upgrade Time: One Hour +#### Estimated Upgrade Time: ? > {note} We attempt to document every possible breaking change. Since some of these breaking changes are in obscure parts of the framework only a portion of these changes may actually affect your application. -### PHP 7.2 Required +### WIP -**Likelihood Of Impact: Medium** - -PHP 7.1 will no longer be actively maintained as of December 2019. Therefore, Laravel 6.0 requires PHP 7.2 or greater. - - -### Updating Dependencies - -Update your `laravel/framework` dependency to `^6.0` in your `composer.json` file. - -Next, examine any 3rd party packages consumed by your application and verify you are using the proper version for Laravel 6 support. - -### Authorization - - -#### Authorized Resources & `viewAny` - -**Likelihood Of Impact: High** - -Authorization policies attached to controllers using the `authorizeResource` method should now define a `viewAny` method, which will be called when a user accesses the controller's `index` method. Otherwise, calls to the `index` method of the controller will be rejected as unauthorized. - - -#### The `RegisterController` Controller - -**Likelihood Of Impact: Medium** - -If you are overriding the `register` or `registered` methods of Laravel's built-in `RegisterController`, you should ensure that you are calling `parent::register` and `parent::registered` from within your respective methods. The dispatching of the `Illuminate\Auth\Events\Registered` event and the logging in of the newly registered user has been moved to the `registered` method, so if you are overriding this method and not calling the parent method, the user registration process will fail. - -#### Authorization Responses - -**Likelihood Of Impact: Low** - -The constructor signature of the `Illuminate\Auth\Access\Response` class has changed. You should update your code accordingly. If you are not constructing authorization responses manually and are only using the `allow` and `deny` instance methods within your policies, no change is required: - - /** - * Create a new response. - * - * @param bool $allowed - * @param string $message - * @param mixed $code - * @return void - */ - public function __construct($allowed, $message = '', $code = null) - - -#### The `Illuminate\Contracts\Auth\Access\Gate` Contract - -**Likelihood Of Impact: Low** - -The `Illuminate\Contracts\Auth\Access\Gate` contract has received a new `inspect` method. If you are implementing this interface manually, you should add this method to your implementation. - -### Carbon - - -#### Carbon 1.x No Longer Supported - -**Likelihood Of Impact: Medium** - -Carbon 1.x [is no longer supported](https://github.com/laravel/framework/pull/28683) since it is nearing its maintenance end of life. Please upgrade your application to Carbon 2.0. - -### Configuration - -#### The `AWS_REGION` Environment Variable - -**Likelihood Of Impact: Optional** - -If you plan to utilize [Laravel Vapor](https://vapor.laravel.com), you should update all occurrences of `AWS_REGION` within your `config` directory to `AWS_DEFAULT_REGION`. In addition, you should update this environment variable's name in your `.env` file. - -### Database - - -#### The Capsule `table` Method - -**Likelihood Of Impact: Medium** - -> {note} This change only applies to non-Laravel applications that are using `illuminate/database` as a dependency. - -The signature of the `Illuminate\Database\Capsule\Manager` class' `table` method has -updated to accept a table alias as its second argument. If you are using `illuminate/database` outside of a Laravel application, you should update any calls to this method accordingly: - - /** - * Get a fluent query builder instance. - * - * @param \Closure|\Illuminate\Database\Query\Builder|string $table - * @param string|null $as - * @param string|null $connection - * @return \Illuminate\Database\Query\Builder - */ - public static function table($table, $as = null, $connection = null) - -#### The `cursor` Method - -**Likelihood Of Impact: Low** - -The `cursor` method now returns an instance of `Illuminate\Support\LazyCollection` instead of a `Generator` The `LazyCollection` may be iterated just like a generator: - - $users = App\User::cursor(); - - foreach ($users as $user) { - // - } - - -### Eloquent - - -#### The `BelongsTo::update` Method - -**Likelihood Of Impact: Medium** - -For consistency, the `update` method of the `BelongsTo` relationship now functions as an ad-hoc update query, meaning it does not provide mass assignment protection or fire Eloquent events. This makes the relationship consistent with the `update` methods on all other types of relationships. - -If you would like to update a model attached via a `BelongsTo` relationship and receive mass assignment update protection and events, you should call the `update` method on the model itself: - - // Ad-hoc query... no mass assignment protection or events... - $post->user()->update(['foo' => 'bar']); - - // Model update... provides mass assignment protection and events... - $post->user->update(['foo' => 'bar']); - - -#### Arrayable & `toArray` - -**Likelihood Of Impact: Medium** - -The Eloquent model's `toArray` method will now cast any attributes that implement `Illuminate\Contracts\Support\Arrayable` to an array. - - -#### Declaration Of Primary Key Type - -**Likelihood Of Impact: Medium** - -Laravel 6.0 has received [performance optimizations](https://github.com/laravel/framework/pull/28153) for integer key types. If you are using a string as your model's primary key, you should declare the key type using the `$keyType` property on your model: - - /** - * The "type" of the primary key ID. - * - * @var string - */ - protected $keyType = 'string'; - -### Email Verification - - -#### Resend Verification Route HTTP Method - -**Likelihood Of Impact: Medium** - -To prevent possible CSRF attacks, the `email/resend` route registered by the router when using Laravel's built-in email verification has been updated from a `GET` route to a `POST` route. Therefore, you will need to update your frontend to send the proper request type to this route. For example, if you are using the built-in email verification template scaffolding: - - {{ __('Before proceeding, please check your email for a verification link.') }} - {{ __('If you did not receive the email') }}, - -
- @csrf - - . -
- - -#### The `MustVerifyEmail` Contract - -**Likelihood Of Impact: Low** - -A new `getEmailForVerification` method has been added to the `Illuminate\Contracts\Auth\MustVerifyEmail` contract. If you are manually implementing this contract, you should implement this method. This method should return the object's associated email address. If your `App\User` model is using the `Illuminate\Auth\MustVerifyEmail` trait, no changes are required, as this trait implements this method for you. - - -### Helpers - -#### String & Array Helpers Package - -**Likelihood Of Impact: High** - -All `str_` and `array_` helpers have been moved to the new `laravel/helpers` Composer package and removed from the framework. If desired, you may update all calls to these helpers to use the `Illuminate\Support\Str` and `Illuminate\Support\Arr` classes. Alternatively, you can add the new `laravel/helpers` package to your application to continue using these helpers: - - composer require laravel/helpers - -### Localization - - -#### The `Lang::trans` & `Lang::transChoice` Methods - -**Likelihood Of Impact: Medium** - -The `Lang::trans` and `Lang::transChoice` methods of the translator have been renamed to `Lang::get` and `Lang::choice`. - -In addition, if you are manually implementing the `Illuminate\Contracts\Translation\Translator` contract, you should update your implementation's `trans` and `transChoice` methods to `get` and `choice`. - - -#### The `Lang::getFromJson` Method - -**Likelihood Of Impact: Medium** - -The `Lang::get` and `Lang::getFromJson` methods have been consolidated. Calls to the `Lang::getFromJson` method should be updated to call `Lang::get`. - -### Mail - -#### Mandrill & SparkPost Drivers Removed - -**Likelihood Of Impact: Low** - -The `mandrill` and `sparkpost` mail drivers have been removed. If you would like to continue using either of these drivers, we encourage you to adopt a community maintained package of your choice that provides the driver. - -### Notifications - -#### Nexmo Routing Removed - -**Likelihood Of Impact: Low** - -A lingering part of the Nexmo notification channel was removed from the core of the framework. If you're relying on routing Nexmo notifications you should manually implement the `routeNotificationForNexmo` method on your notifiable entity [as described in the documentation](/docs/{{version}}/notifications#routing-sms-notifications). - -### Password Reset - -#### Password Validation - -**Likelihood Of Impact: Low** - -The `PasswordBroker` no longer restricts or validates passwords. Password validation was already being handled by the `ResetPasswordController` class, making the broker's validations redundant and impossible to customize. If you are manually using the `PasswordBroker` (or `Password` facade) outside of the built-in `ResetPasswordController`, you should validate all passwords before passing them to the broker. - -### Queues - - -#### Queue Retry Limit - -**Likelihood Of Impact: Medium** - -In previous releases of Laravel, the `php artisan queue:work` command would retry jobs indefinitely. Beginning with Laravel 6.0, this command will now try a job one time by default. If you would like to force jobs to be tried indefinitely, you may pass `0` to the `--tries` option: - - php artisan queue:work --tries=0 - -In addition, please ensure your application's database contains a `failed_jobs` table. You can generate a migration for this table using the `queue:failed-table` Artisan command: - - php artisan queue:failed-table - -### Requests - - -#### The `Input` Facade - -**Likelihood Of Impact: Medium** - -The `Input` facade, which was primarily a duplicate of the `Request` facade, has been removed. If you are using the `Input::get` method, you should now call the `Request::input` method. All other calls to the `Input` facade may simply be updated to use the `Request` facade. - -### Scheduling - -#### The `between` Method - -**Likelihood Of Impact: Low** - -In previous releases of Laravel, the scheduler's `between` method exhibited confusing behavior across date boundaries. For example: - - $schedule->command('list')->between('23:00', '4:00'); - -For most users, the expected behavior of this method would be to run the `list` command every minute for all minutes between 23:00 and 4:00. However, in previous releases of Laravel, the scheduler ran the `list` command every minute between 4:00 and 23:00, essentially swapping the time thresholds. In Laravel 6.0, this behavior has been corrected. - -### Storage - - -#### Rackspace Storage Driver Removed - -**Likelihood Of Impact: Low** - -The `rackspace` storage driver has been removed. If you would like to continue using Rackspace as a storage provider, we encourage you to adopt a community maintained package of your choice that provides this driver. +Upgrade notes will be placed here. ### Miscellaneous -We also encourage you to view the changes in the `laravel/laravel` [GitHub repository](https://github.com/laravel/laravel). While many of these changes are not required, you may wish to keep these files in sync with your application. Some of these changes will be covered in this upgrade guide, but others, such as changes to configuration files or comments, will not be. You can easily view the changes with the [GitHub comparison tool](https://github.com/laravel/laravel/compare/5.8...master) and choose which updates are important to you. +We also encourage you to view the changes in the `laravel/laravel` [GitHub repository](https://github.com/laravel/laravel). While many of these changes are not required, you may wish to keep these files in sync with your application. Some of these changes will be covered in this upgrade guide, but others, such as changes to configuration files or comments, will not be. You can easily view the changes with the [GitHub comparison tool](https://github.com/laravel/laravel/compare/6.0...master) and choose which updates are important to you. From 0ec960580dc5f596333fda9598049ac071b30425 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Mon, 2 Dec 2019 20:09:09 +0100 Subject: [PATCH 2/8] Update upgrade guide --- upgrade.md | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/upgrade.md b/upgrade.md index fcf400213cb..b506a0519df 100644 --- a/upgrade.md +++ b/upgrade.md @@ -6,16 +6,14 @@ ## High Impact Changes
-- ... +- [Date Serialization](#date-serialization)
## Medium Impact Changes
- - ... -
@@ -25,9 +23,45 @@ > {note} We attempt to document every possible breaking change. Since some of these breaking changes are in obscure parts of the framework only a portion of these changes may actually affect your application. -### WIP +### Symfony 5 Required + +**Likelihood Of Impact: Medium** + +Laravel 7 adds support for Symfony 5 which is now also the new minimum compatible version. + +### PHP 7.2.5 Required + +**Likelihood Of Impact: Low** + +The new minimum PHP version (which mimics Symfony 5.0) is now 7.2.5. + + +### Updating Dependencies + +Update your `laravel/framework` dependency to `^7.0` in your `composer.json` file. + +Next, examine any 3rd party packages consumed by your application and verify you are using the proper version for Laravel 7 support. + +### Eloquent + + +#### Date Serialization + +**Likelihood Of Impact: High** + +Laravel 7 comes with a new default for serializing dates when using the `toArray` or `toJson` method on Eloquent models. It makes use of the default Carbon `toJSON` behavior and will provide a datetime string with fractions and timezone info. + +The previous behavior would serialize a date, for example, to `2019-12-02 20:01:00`. The new behavior will serialize a date to something like `2019-12-02T20:01:00.283041Z`. This will provide more info if you're, for example, building API's. + +If you want to keep using the previous behavior you can override the `serializeDate` method on your model: -Upgrade notes will be placed here. + /** + * Prepare a date for array / JSON serialization. + */ + protected function serializeDate(DateTimeInterface $date) : string + { + return $date->format('Y-m-d H:i:s'); + } ### Miscellaneous From e5d2d215094b1c97cc3309c406383e180fb043c3 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Mon, 2 Dec 2019 20:13:04 +0100 Subject: [PATCH 3/8] Document default date serialization --- eloquent-serialization.md | 15 +++++++++++++++ upgrade.md | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/eloquent-serialization.md b/eloquent-serialization.md index 5430db0e383..97e8f3004ac 100644 --- a/eloquent-serialization.md +++ b/eloquent-serialization.md @@ -170,6 +170,21 @@ You may instruct a single model instance to append attributes using the `append` ## Date Serialization +#### Customizing The Default Date Format + +You may customize the default serialization format by overriding the `serializeDate` method: + + /** + * Prepare a date for array / JSON serialization. + * + * @param \DateTimeInterface $date + * @return string + */ + protected function serializeDate(DateTimeInterface $date) + { + return $date->format('Y-m-d'); + } + #### Customizing The Date Format Per Attribute You may customize the serialization format of individual Eloquent date attributes by specifying the date format in the [cast declaration](/docs/{{version}}/eloquent-mutators#attribute-casting): diff --git a/upgrade.md b/upgrade.md index b506a0519df..e350b529879 100644 --- a/upgrade.md +++ b/upgrade.md @@ -57,8 +57,11 @@ If you want to keep using the previous behavior you can override the `serializeD /** * Prepare a date for array / JSON serialization. + * + * @param \DateTimeInterface $date + * @return string */ - protected function serializeDate(DateTimeInterface $date) : string + protected function serializeDate(DateTimeInterface $date) { return $date->format('Y-m-d H:i:s'); } From c388d8d797a88085cd05ebd2e7d3f48c051290d5 Mon Sep 17 00:00:00 2001 From: Victor Gazotti Date: Tue, 3 Dec 2019 12:05:42 -0300 Subject: [PATCH 4/8] [7.x] Document sortDesc method Documents the `sortDesc`method added in `Collection` at https://github.com/laravel/framework/pull/30672 --- collections.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/collections.md b/collections.md index 60c79937073..dd48e942229 100644 --- a/collections.md +++ b/collections.md @@ -156,6 +156,7 @@ For the remainder of this documentation, we'll discuss each method available on [sort](#method-sort) [sortBy](#method-sortby) [sortByDesc](#method-sortbydesc) +[sortDesc](#method-sortdesc) [sortKeys](#method-sortkeys) [sortKeysDesc](#method-sortkeysdesc) [splice](#method-splice) @@ -1788,6 +1789,19 @@ You can also pass your own callback to determine how to sort the collection valu This method has the same signature as the [`sortBy`](#method-sortby) method, but will sort the collection in the opposite order. + +#### `sortDesc()` {#collection-method} + +This method has the same signature as the [`sort`](#method-sort) method, but will sort the collection in the opposite order: + + $collection = collect([5, 3, 1, 2, 4]); + + $sorted = $collection->sortDesc(); + + $sorted->values()->all(); + + // [5, 4, 3, 2, 1] + #### `sortKeys()` {#collection-method} From 2aa1be476156b1ef9a4e58aa35afa80603c00342 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 4 Dec 2019 14:10:09 -0600 Subject: [PATCH 5/8] formatting --- upgrade.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/upgrade.md b/upgrade.md index e350b529879..7d5493f8ba6 100644 --- a/upgrade.md +++ b/upgrade.md @@ -27,13 +27,13 @@ **Likelihood Of Impact: Medium** -Laravel 7 adds support for Symfony 5 which is now also the new minimum compatible version. +Laravel 7 upgrade its underlying Symfony components to the 5.x series, which is now also the new minimum compatible version. ### PHP 7.2.5 Required **Likelihood Of Impact: Low** -The new minimum PHP version (which mimics Symfony 5.0) is now 7.2.5. +The new minimum PHP version is now 7.2.5. ### Updating Dependencies @@ -49,11 +49,11 @@ Next, examine any 3rd party packages consumed by your application and verify you **Likelihood Of Impact: High** -Laravel 7 comes with a new default for serializing dates when using the `toArray` or `toJson` method on Eloquent models. It makes use of the default Carbon `toJSON` behavior and will provide a datetime string with fractions and timezone info. +Laravel 7 uses a new date serialization format when using the `toArray` or `toJson` method on Eloquent models. To format dates for serialization, the framework now uses Carbon's `toJSON` method, which produces an ISO-8601 compatible date including timezone information and fractional seconds and better integration with client-side date parsing libraries. -The previous behavior would serialize a date, for example, to `2019-12-02 20:01:00`. The new behavior will serialize a date to something like `2019-12-02T20:01:00.283041Z`. This will provide more info if you're, for example, building API's. +Previously, dates would be serialized to a format like the following: `2019-12-02 20:01:00`. Dates serialized using the new format will appear like: `2019-12-02T20:01:00.283041Z`. -If you want to keep using the previous behavior you can override the `serializeDate` method on your model: +If you would like to keep using the previous behavior you can override the `serializeDate` method on your model: /** * Prepare a date for array / JSON serialization. @@ -66,6 +66,8 @@ If you want to keep using the previous behavior you can override the `serializeD return $date->format('Y-m-d H:i:s'); } +> {tip} This change only affects serialization of models and model collections to arrays and JSON. This change has no affect on how dates are stored in your database. + ### Miscellaneous From 3d6936998f3eba9884aed8da68229af5d1deab7b Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 4 Dec 2019 14:10:41 -0600 Subject: [PATCH 6/8] formatting --- upgrade.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upgrade.md b/upgrade.md index 7d5493f8ba6..f09470245e5 100644 --- a/upgrade.md +++ b/upgrade.md @@ -49,7 +49,7 @@ Next, examine any 3rd party packages consumed by your application and verify you **Likelihood Of Impact: High** -Laravel 7 uses a new date serialization format when using the `toArray` or `toJson` method on Eloquent models. To format dates for serialization, the framework now uses Carbon's `toJSON` method, which produces an ISO-8601 compatible date including timezone information and fractional seconds and better integration with client-side date parsing libraries. +Laravel 7 uses a new date serialization format when using the `toArray` or `toJson` method on Eloquent models. To format dates for serialization, the framework now uses Carbon's `toJSON` method, which produces an ISO-8601 compatible date including timezone information and fractional seconds. In addition, this change provides better support and integration with client-side date parsing libraries. Previously, dates would be serialized to a format like the following: `2019-12-02 20:01:00`. Dates serialized using the new format will appear like: `2019-12-02T20:01:00.283041Z`. From 9e8c49b7a8a9c0e4a992b215669d0bcdcab98a7a Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 5 Dec 2019 14:42:36 -0600 Subject: [PATCH 7/8] fix call --- eloquent-resources.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eloquent-resources.md b/eloquent-resources.md index 58235fb261b..bab01f4ea9e 100644 --- a/eloquent-resources.md +++ b/eloquent-resources.md @@ -318,7 +318,7 @@ If you would like to disable the wrapping of the outer-most resource, you may us namespace App\Providers; - use Illuminate\Http\Resources\Json\Resource; + use Illuminate\Http\Resources\Json\JsonResource; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider @@ -340,7 +340,7 @@ If you would like to disable the wrapping of the outer-most resource, you may us */ public function boot() { - Resource::withoutWrapping(); + JsonResource::withoutWrapping(); } } From d6cd4850ce9625f50b91b88744326f633f6546e3 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 13 Dec 2019 15:17:48 -0600 Subject: [PATCH 8/8] add documentation on the `fitContent` method goes with https://github.com/laravel/dusk/pull/655 going to start looking into being able to configure it to auto fit before taking screenshots of failures. --- dusk.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dusk.md b/dusk.md index d0dba320db1..5ddd836925f 100644 --- a/dusk.md +++ b/dusk.md @@ -248,6 +248,10 @@ The `maximize` method may be used to maximize the browser window: $browser->maximize(); +The `fitContent` method will resize the browser window to match the size of the content: + + $browser->fitContent(); + ### Browser Macros