Querying using Eloquent ORM
Laravel provides many ways to interact with databases. One of the easiest ways is using the Eloquent ORM. It provides a simple and intuitive way to work with data.
Getting ready
For this recipe, we'll be using the table created in the Creating data tables using migrations and schemas recipe.
How to do it...
To complete this recipe, follow these steps:
In the command prompt, create a migration so we can add some data:
php artisan migrate:make add_data_to_shows_table
In our
app/database/migrations
directory, find a file similar to2012_01_01_222551_add_data_to_shows_table.php
, and add some data using the Fluent query builder:class AddDataToShowsTable { /** * Make changes to the database. * * @return void */ public function up() { $data1 = array('name' => 'Doctor Who', 'rating' => 9, 'actor' => 'Matt Smith'); $data2 = array('name' => 'Arrested Development', 'rating' => 10, 'actor'...