Skip to content

Commit

Permalink
DOCSP-38076 quickstart updates for 11 (#2799)
Browse files Browse the repository at this point in the history
* DOCSP-38076: quick start changes for Laravel 11
  • Loading branch information
Chris Cho authored Apr 3, 2024
1 parent c6b683e commit e338fc2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docs/quick-start.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ that connects to a MongoDB deployment.
.. tip::

You can download the complete web application project by cloning the
`laravel-quickstart <https://github.com/mongodb-university/laravel-quickstart>`__
`laravel-quickstart <https://github.com/mongodb-university/laravel-quickstart/>`__
GitHub repository.

.. button:: Next: Download and Install
Expand Down
11 changes: 8 additions & 3 deletions docs/quick-start/configure-mongodb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,20 @@ Configure Your MongoDB Connection

// ...

.. step:: Add the Laravel MongoDB provider
.. step:: Add the MongoDB provider

Open the ``app.php`` file in the ``config`` directory and
add the following entry into the ``providers`` array:
Open the ``providers.php`` file in the ``bootstrap`` directory and add
the following entry into the array:

.. code-block::

MongoDB\Laravel\MongoDBServiceProvider::class,

.. tip::

To learn how to register the provider in Laravel 10.x, see
`Registering Providers <https://laravel.com/docs/10.x/providers#registering-providers>`__.

After completing these steps, your Laravel web application is ready to
connect to MongoDB.

Expand Down
14 changes: 7 additions & 7 deletions docs/quick-start/view-data.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ View MongoDB Data

public function show()
{
return view('browse_movies', [
'movies' => Movie::where('runtime', '<', 60)
->where('imdb.rating', '>', 8.5)
->orderBy('imdb.rating', 'desc')
->take(10)
->get()
]);
return view('browse_movies', [
'movies' => Movie::where('runtime', '<', 60)
->where('imdb.rating', '>', 8.5)
->orderBy('imdb.rating', 'desc')
->take(10)
->get()
]);
}

.. step:: Add a web route
Expand Down
17 changes: 14 additions & 3 deletions docs/quick-start/write-data.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ Write Data to MongoDB

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

Generate an API route file by running the following command:

.. code-block:: bash

php artisan install:api

.. tip::

Skip this step if you are using Laravel 10.x because the file that
the command generates already exists.

Import the controller and add an API route that calls the ``store()``
method in the ``routes/api.php`` file:

Expand All @@ -42,7 +53,7 @@ Write Data to MongoDB
// ...

Route::resource('movies', MovieController::class)->only([
'store'
'store'
]);


Expand All @@ -57,8 +68,8 @@ Write Data to MongoDB

class Movie extends Model
{
protected $connection = 'mongodb';
protected $fillable = ['title', 'year', 'runtime', 'imdb', 'plot'];
protected $connection = 'mongodb';
protected $fillable = ['title', 'year', 'runtime', 'imdb', 'plot'];
}

.. step:: Post a request to the API
Expand Down

0 comments on commit e338fc2

Please sign in to comment.