Skip to content

Commit cfb2c4c

Browse files
author
Chris Cho
committed
DOCSP-38076: quick start changes for Laravel 11
1 parent 260620e commit cfb2c4c

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

docs/quick-start/configure-mongodb.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,18 @@ Configure Your MongoDB Connection
4141

4242
// ...
4343

44-
.. step:: Add the Laravel MongoDB provider
44+
.. step:: Add the MongoDB provider
4545

46-
Open the ``app.php`` file in the ``config`` directory and
47-
add the following entry into the ``providers`` array:
46+
Open the ``providers.php`` file in the ``bootstrap`` directory and add
47+
the following entry into the array:
4848

4949
.. code-block::
5050

5151
MongoDB\Laravel\MongoDBServiceProvider::class,
5252

53+
To learn how to register the provider in Laravel 10.x, see
54+
`Registering Providers <https://laravel.com/docs/10.x/providers#registering-providers>`__.
55+
5356
After completing these steps, your Laravel web application is ready to
5457
connect to MongoDB.
5558

docs/quick-start/view-data.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ View MongoDB Data
6767

6868
public function show()
6969
{
70-
return view('browse_movies', [
71-
'movies' => Movie::where('runtime', '<', 60)
72-
->where('imdb.rating', '>', 8.5)
73-
->orderBy('imdb.rating', 'desc')
74-
->take(10)
75-
->get()
76-
]);
70+
return view('browse_movies', [
71+
'movies' => Movie::where('runtime', '<', 60)
72+
->where('imdb.rating', '>', 8.5)
73+
->orderBy('imdb.rating', 'desc')
74+
->take(10)
75+
->get()
76+
]);
7777
}
7878

7979
.. step:: Add a web route

docs/quick-start/write-data.txt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ Write Data to MongoDB
3232

3333
.. step:: Add an API route that calls the controller function
3434

35+
Generate an API route file by running the following command:
36+
37+
.. code-block:: bash
38+
39+
php artisan install:api
40+
41+
.. tip::
42+
43+
For Laravel 10.x and earlier, you do not need to run this command.
44+
3545
Import the controller and add an API route that calls the ``store()``
3646
method in the ``routes/api.php`` file:
3747

@@ -42,7 +52,7 @@ Write Data to MongoDB
4252
// ...
4353

4454
Route::resource('movies', MovieController::class)->only([
45-
'store'
55+
'store'
4656
]);
4757

4858

@@ -57,8 +67,8 @@ Write Data to MongoDB
5767

5868
class Movie extends Model
5969
{
60-
protected $connection = 'mongodb';
61-
protected $fillable = ['title', 'year', 'runtime', 'imdb', 'plot'];
70+
protected $connection = 'mongodb';
71+
protected $fillable = ['title', 'year', 'runtime', 'imdb', 'plot'];
6272
}
6373

6474
.. step:: Post a request to the API

0 commit comments

Comments
 (0)