There are over cats on this site!
Then, return the view using the
view()
helper function with the variable,
$number_of_cats
:
Route::get('about', function() {
return view('about')->with('number_of_cats', 9000);
});
Finally, visit
/about
in your browser to see the rendered view. This view was written
with plain PHP; however, Laravel comes with a powerful template language called
Blade, which will be introduced later in this chapter.
Preparing the database
Before we can expand the functionality of our routes, we need to define the models
of our application, prepare the necessary database schema, and populate the
database with some initial data.
Homestead ships with a MySQL server built in, so we can use MySQL for our
database; however, it does require a little bit of configuration first, before we can use
a MySQL database in our application.
The first step is to open our application's configuration file, which should have been
created at
.env
when we created the application with Composer. Find the line that
says
DB_DATABASE=homestead
and change it to
DB_DATABASE=furbook
.
Chapter 3
Do'stlaringiz bilan baham: |