Skip to content

Commit af2a950

Browse files
nunomadurotaylorotwellJubeki
authored
[main] Adjusts for Laravel 11 (#64)
* Adjusts for Laravel 11 * Update resources/docs/blade/creating-chirps.md Co-authored-by: Julius Kiekbusch <[email protected]> * Update installation.md * formatting " * Update installation.md --------- Co-authored-by: Taylor Otwell <[email protected]> Co-authored-by: Julius Kiekbusch <[email protected]>
1 parent 1335d26 commit af2a950

File tree

10 files changed

+60
-134
lines changed

10 files changed

+60
-134
lines changed

resources/docs/blade/creating-chirps.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,11 @@ We are also going to place these routes behind two [middleware](https://laravel.
4747

4848
use App\Http\Controllers\ChirpController;// [tl! add]
4949
use Illuminate\Support\Facades\Route;
50-
// [tl! collapse:start]
51-
/*
52-
|--------------------------------------------------------------------------
53-
| Web Routes
54-
|--------------------------------------------------------------------------
55-
|
56-
| Here is where you can register web routes for your application. These
57-
| routes are loaded by the RouteServiceProvider within a group which
58-
| contains the "web" middleware group. Now create something great!
59-
|
60-
*/
6150

6251
Route::get('/', function () {
6352
return view('welcome');
6453
});
65-
// [tl! collapse:end]
54+
6655
Route::get('/dashboard', function () {
6756
return view('dashboard');
6857
})->middleware(['auth', 'verified'])->name('dashboard');
@@ -429,13 +418,17 @@ class User extends Authenticatable
429418
];
430419

431420
/**
432-
* The attributes that should be cast.
421+
* Get the attributes that should be cast.
433422
*
434-
* @var array<string, string>
423+
* @return array<string, string>
435424
*/
436-
protected $casts = [
437-
'email_verified_at' => 'datetime',
438-
];
425+
protected function casts(): array
426+
{
427+
return [
428+
'email_verified_at' => 'datetime',
429+
'password' => 'hashed',
430+
];
431+
}
439432
// [tl! collapse:end]
440433
public function chirps(): HasMany// [tl! add:start]
441434
{
@@ -478,7 +471,14 @@ You can learn more about Laravel's mass assignment protection in the [documentat
478471

479472
## Updating the migration
480473

481-
The only thing missing is extra columns in our database to store the relationship between a `Chirp` and its `User` and the message itself. Remember the database migration we created earlier? It's time to open that file to add some extra columns:
474+
During the creation of the application, Laravel already applied the default migrations that are included in the `database/migrations` directory. You may inspect the current database structure by using the `php artisan db:show` and `php artisan db:table` commands:
475+
476+
```shell
477+
php artisan db:show
478+
php artisan db:table users
479+
```
480+
481+
So, the only thing missing is extra columns in our database to store the relationship between a `Chirp` and its `User` and the message itself. Remember the database migration we created earlier? It's time to open that file to add some extra columns:
482482

483483
```php filename=databases/migrations/&amp;lt;timestamp&amp;gt;_create_chirps_table.php
484484
<?php

resources/docs/blade/deleting-chirps.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,6 @@ We'll start again by updating our routes to enable the `chirps.destroy` route:
1616
use App\Http\Controllers\ChirpController;
1717
use Illuminate\Support\Facades\Route;
1818

19-
/*
20-
|--------------------------------------------------------------------------
21-
| Web Routes
22-
|--------------------------------------------------------------------------
23-
|
24-
| Here is where you can register web routes for your application. These
25-
| routes are loaded by the RouteServiceProvider within a group which
26-
| contains the "web" middleware group. Now create something great!
27-
|
28-
*/
29-
3019
Route::get('/', function () {
3120
return view('welcome');
3221
});

resources/docs/blade/editing-chirps.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,6 @@ First we will update our routes file to enable the `chirps.edit` and `chirps.upd
1414
use App\Http\Controllers\ChirpController;
1515
use Illuminate\Support\Facades\Route;
1616

17-
/*
18-
|--------------------------------------------------------------------------
19-
| Web Routes
20-
|--------------------------------------------------------------------------
21-
|
22-
| Here is where you can register web routes for your application. These
23-
| routes are loaded by the RouteServiceProvider within a group which
24-
| contains the "web" middleware group. Now create something great!
25-
|
26-
*/
27-
2817
Route::get('/', function () {
2918
return view('welcome');
3019
});

resources/docs/blade/installation.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ composer create-project laravel/laravel chirper
1515
> **Note**
1616
> You will need a [supported version of PHP](https://www.php.net/supported-versions.php) before continuing. You may check your installation by running the `php -v` command. Alternatively, you may follow the <a href="#docker">instructions for Docker</a>.
1717
18-
After the project has been created, start Laravel's local development server using the Laravel's Artisan CLI serve command:
18+
For simplicity, Composer's `create-project` command will automatically create a new SQLite database at `database/database.sqlite` to store your application's data. After the project has been created, start Laravel's local development server using Laravel Artisan's `serve` command:
1919

2020
```none
2121
cd chirper
@@ -28,12 +28,6 @@ Once you have started the Artisan development server, your application will be a
2828
<img src="/img/screenshots/fresh.png" alt="A fresh Laravel installation" class="dark:hidden rounded-lg border shadow-lg" />
2929
<img src="/img/screenshots/fresh-dark.png" alt="A fresh Laravel installation" class="hidden dark:block rounded-lg border-gray-700 shadow-lg" />
3030

31-
For simplicity, you may use SQLite to store your application's data. To instruct Laravel to use SQLite instead of MySQL, update your new application's `.env` file and remove all of the `DB_*` environment variables except for the `DB_CONNECTION` variable, which should be set to `sqlite`:
32-
33-
```ini
34-
DB_CONNECTION=sqlite
35-
```
36-
3731
<a name="docker"></a>
3832
### Installation via Docker
3933

@@ -47,7 +41,7 @@ curl -s "https://laravel.build/chirper" | bash
4741

4842
Sail installation may take several minutes while Sail's application containers are built on your local machine.
4943

50-
By default, the installer will pre-configure Laravel Sail with a number of useful services for your application, including a MySQL database server. You may [customize the Sail services](https://laravel.com/docs/installation#choosing-your-sail-services) if needed.
44+
By default, the installer will pre-configure Laravel Sail with a number of useful services for your application, including a MySQL database server if you wish to use MySQL instead of SQLite. You may [customize the Sail services](https://laravel.com/docs/installation#choosing-your-sail-services) if needed.
5145

5246
After the project has been created, you can navigate to the application directory and start Laravel Sail:
5347

@@ -94,12 +88,6 @@ Breeze will install and configure your front-end dependencies for you, so we jus
9488
npm run dev
9589
```
9690

97-
Finally, open another terminal in your `chirper` project directory and run the initial database migrations to populate the database with the default tables from Laravel and Breeze:
98-
99-
```shell
100-
php artisan migrate
101-
```
102-
10391
If you refresh your new Laravel application in the browser, you should now see a "Register" link at the top-right. Follow that to see the registration form provided by Laravel Breeze.
10492

10593
<img src="/img/screenshots/register.png" alt="Laravel registration page" class="rounded-lg border dark:border-none shadow-lg" />

resources/docs/inertia/creating-chirps.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,6 @@ use App\Http\Controllers\ChirpController;// [tl! add]
4949
use Illuminate\Foundation\Application;
5050
use Illuminate\Support\Facades\Route;
5151
use Inertia\Inertia;
52-
// [tl! collapse:start]
53-
/*
54-
|--------------------------------------------------------------------------
55-
| Web Routes
56-
|--------------------------------------------------------------------------
57-
|
58-
| Here is where you can register web routes for your application. These
59-
| routes are loaded by the RouteServiceProvider within a group which
60-
| contains the "web" middleware group. Now create something great!
61-
|
62-
*/
6352

6453
Route::get('/', function () {
6554
return Inertia::render('Welcome', [
@@ -69,7 +58,7 @@ Route::get('/', function () {
6958
'phpVersion' => PHP_VERSION,
7059
]);
7160
});
72-
// [tl! collapse:end]
61+
7362
Route::get('/dashboard', function () {
7463
return Inertia::render('Dashboard');
7564
})->middleware(['auth', 'verified'])->name('dashboard');
@@ -519,13 +508,17 @@ class User extends Authenticatable
519508
];
520509

521510
/**
522-
* The attributes that should be cast.
511+
* Get the attributes that should be cast.
523512
*
524-
* @var array<string, string>
513+
* @return array<string, string>
525514
*/
526-
protected $casts = [
527-
'email_verified_at' => 'datetime',
528-
];
515+
protected function casts(): array
516+
{
517+
return [
518+
'email_verified_at' => 'datetime',
519+
'password' => 'hashed',
520+
];
521+
}
529522
// [tl! collapse:end]
530523
public function chirps(): HasMany// [tl! add:start]
531524
{
@@ -568,7 +561,14 @@ You can learn more about Laravel's mass assignment protection in the [documentat
568561

569562
## Updating the migration
570563

571-
The only thing missing is extra columns in our database to store the relationship between a `Chirp` and its `User` and the message itself. Remember the database migration we created earlier? It's time to open that file to add some extra columns:
564+
During the creation of the application, Laravel already applied the default migrations that are included in the `database/migrations` directory. You may inspect the current database structure by using the `php artisan db:show` and `php artisan db:table` commands:
565+
566+
```shell
567+
php artisan db:show
568+
php artisan db:table users
569+
```
570+
571+
So, the only thing missing is extra columns in our database to store the relationship between a `Chirp` and its `User` and the message itself. Remember the database migration we created earlier? It's time to open that file to add some extra columns:
572572

573573
```php filename=databases/migrations/&amp;lt;timestamp&amp;gt;_create_chirps_table.php
574574
<?php

resources/docs/inertia/deleting-chirps.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,6 @@ use Illuminate\Foundation\Application;
1818
use Illuminate\Support\Facades\Route;
1919
use Inertia\Inertia;
2020

21-
/*
22-
|--------------------------------------------------------------------------
23-
| Web Routes
24-
|--------------------------------------------------------------------------
25-
|
26-
| Here is where you can register web routes for your application. These
27-
| routes are loaded by the RouteServiceProvider within a group which
28-
| contains the "web" middleware group. Now create something great!
29-
|
30-
*/
31-
3221
Route::get('/', function () {
3322
return Inertia::render('Welcome', [
3423
'canLogin' => Route::has('login'),

resources/docs/inertia/editing-chirps.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,6 @@ use Illuminate\Foundation\Application;
1616
use Illuminate\Support\Facades\Route;
1717
use Inertia\Inertia;
1818

19-
/*
20-
|--------------------------------------------------------------------------
21-
| Web Routes
22-
|--------------------------------------------------------------------------
23-
|
24-
| Here is where you can register web routes for your application. These
25-
| routes are loaded by the RouteServiceProvider within a group which
26-
| contains the "web" middleware group. Now create something great!
27-
|
28-
*/
29-
3019
Route::get('/', function () {
3120
return Inertia::render('Welcome', [
3221
'canLogin' => Route::has('login'),

resources/docs/inertia/installation.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ composer create-project laravel/laravel chirper
1515
> **Note**
1616
> You will need a [supported version of PHP](https://www.php.net/supported-versions.php) before continuing. You may check your installation by running the `php -v` command. Alternatively, you may follow the <a href="#docker">instructions for Docker</a>.
1717
18-
After the project has been created, start Laravel's local development server using the Laravel's Artisan CLI serve command:
18+
For simplicity, Composer's `create-project` command will automatically create a new SQLite database at `database/database.sqlite` to store your application's data. After the project has been created, start Laravel's local development server using Laravel Artisan's `serve` command:
1919

2020
```none
2121
cd chirper
@@ -28,12 +28,6 @@ Once you have started the Artisan development server, your application will be a
2828
<img src="/img/screenshots/fresh.png" alt="A fresh Laravel installation" class="dark:hidden rounded-lg border shadow-lg" />
2929
<img src="/img/screenshots/fresh-dark.png" alt="A fresh Laravel installation" class="hidden dark:block rounded-lg border-gray-700 shadow-lg" />
3030

31-
For simplicity, you may use SQLite to store your application's data. To instruct Laravel to use SQLite instead of MySQL, update your new application's `.env` file and remove all of the `DB_*` environment variables except for the `DB_CONNECTION` variable, which should be set to `sqlite`:
32-
33-
```ini
34-
DB_CONNECTION=sqlite
35-
```
36-
3731
<a name="docker"></a>
3832
### Installation via Docker
3933

@@ -47,7 +41,7 @@ curl -s "https://laravel.build/chirper" | bash
4741

4842
Sail installation may take several minutes while Sail's application containers are built on your local machine.
4943

50-
By default, the installer will pre-configure Laravel Sail with a number of useful services for your application, including a MySQL database server. You may [customize the Sail services](https://laravel.com/docs/installation#choosing-your-sail-services) if needed.
44+
By default, the installer will pre-configure Laravel Sail with a number of useful services for your application, including a MySQL database server if you wish to use MySQL instead of SQLite. You may [customize the Sail services](https://laravel.com/docs/installation#choosing-your-sail-services) if needed.
5145

5246
After the project has been created, you can navigate to the application directory and start Laravel Sail:
5347

@@ -100,12 +94,6 @@ Breeze will install and configure your front-end dependencies for you, so we jus
10094
npm run dev
10195
```
10296

103-
Finally, open another terminal in your `chirper` project directory and run the initial database migrations to populate the database with the default tables from Laravel and Breeze:
104-
105-
```shell
106-
php artisan migrate
107-
```
108-
10997
If you refresh your new Laravel application in the browser, you should now see a "Register" link at the top-right. Follow that to see the registration form provided by Laravel Breeze.
11098

11199
<img src="/img/screenshots/register.png" alt="Laravel registration page" class="rounded-lg border dark:border-none shadow-lg" />

resources/docs/livewire/creating-chirps.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,7 @@ Because we're using Livewire, we only need to define a single `Route::get` route
4444

4545
use App\Http\Controllers\ChirpController;// [tl! add]
4646
use Illuminate\Support\Facades\Route;
47-
// [tl! collapse:start]
48-
/*
49-
|--------------------------------------------------------------------------
50-
| Web Routes
51-
|--------------------------------------------------------------------------
52-
|
53-
| Here is where you can register web routes for your application. These
54-
| routes are loaded by the RouteServiceProvider and all of them will
55-
| be assigned to the "web" middleware group. Make something great!
56-
|
57-
*/
58-
// [tl! collapse:end]
47+
5948
Route::view('/', 'welcome');
6049
// [tl! add:start]
6150
Route::get('chirps', [ChirpController::class, 'index'])
@@ -362,13 +351,17 @@ class User extends Authenticatable
362351
];
363352

364353
/**
365-
* The attributes that should be cast.
354+
* Get the attributes that should be cast.
366355
*
367-
* @var array<string, string>
356+
* @return array<string, string>
368357
*/
369-
protected $casts = [
370-
'email_verified_at' => 'datetime',
371-
];
358+
protected function casts(): array
359+
{
360+
return [
361+
'email_verified_at' => 'datetime',
362+
'password' => 'hashed',
363+
];
364+
}
372365
// [tl! collapse:end]
373366
public function chirps(): HasMany// [tl! add:start]
374367
{
@@ -411,7 +404,14 @@ You can learn more about Laravel's mass assignment protection in the [documentat
411404

412405
## Updating the migration
413406

414-
The only thing missing is extra columns in our database to store the relationship between a `Chirp` and its `User` and the message itself. Remember the database migration we created earlier? It's time to open that file to add some extra columns:
407+
During the creation of the application, Laravel already applied the default migrations that are included in the `database/migrations` directory. You may inspect the current database structure by using the `php artisan db:show` and `php artisan db:table` commands:
408+
409+
```shell
410+
php artisan db:show
411+
php artisan db:table users
412+
```
413+
414+
So, the only thing missing is extra columns in our database to store the relationship between a `Chirp` and its `User` and the message itself. Remember the database migration we created earlier? It's time to open that file to add some extra columns:
415415

416416
```php filename=databases/migrations/&amp;lt;timestamp&amp;gt;_create_chirps_table.php
417417
<?php

resources/docs/livewire/installation.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ composer create-project laravel/laravel chirper
1515
> **Note**
1616
> You will need a [supported version of PHP](https://www.php.net/supported-versions.php) before continuing. You may check your installation by running the `php -v` command. Alternatively, you may follow the <a href="#docker">instructions for Docker</a>.
1717
18-
After the project has been created, start Laravel's local development server using the Laravel's Artisan CLI serve command:
18+
For simplicity, Composer's `create-project` command will automatically create a new SQLite database at `database/database.sqlite` to store your application's data. After the project has been created, start Laravel's local development server using the Laravel Artisan's `serve` command:
1919

2020
```none
2121
cd chirper
@@ -28,12 +28,6 @@ Once you have started the Artisan development server, your application will be a
2828
<img src="/img/screenshots/fresh.png" alt="A fresh Laravel installation" class="dark:hidden rounded-lg border shadow-lg" />
2929
<img src="/img/screenshots/fresh-dark.png" alt="A fresh Laravel installation" class="hidden dark:block rounded-lg border-gray-700 shadow-lg" />
3030

31-
For simplicity, you may use SQLite to store your application's data. To instruct Laravel to use SQLite instead of MySQL, update your new application's `.env` file and remove all of the `DB_*` environment variables except for the `DB_CONNECTION` variable, which should be set to `sqlite`:
32-
33-
```ini
34-
DB_CONNECTION=sqlite
35-
```
36-
3731
<a name="docker"></a>
3832
### Installation via Docker
3933

@@ -47,7 +41,7 @@ curl -s "https://laravel.build/chirper" | bash
4741

4842
Sail installation may take several minutes while Sail's application containers are built on your local machine.
4943

50-
By default, the installer will pre-configure Laravel Sail with a number of useful services for your application, including a MySQL database server. You may [customize the Sail services](https://laravel.com/docs/installation#choosing-your-sail-services) if needed.
44+
By default, the installer will pre-configure Laravel Sail with a number of useful services for your application, including a MySQL database server just in case you decide to use MySQL instead of SQLite. You may [customize the Sail services](https://laravel.com/docs/installation#choosing-your-sail-services) if needed.
5145

5246
After the project has been created, you can navigate to the application directory and start Laravel Sail:
5347

0 commit comments

Comments
 (0)