O'Reilly logo

Learning Laravel's Eloquent by Francesco Malatesta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Create, read, update, and delete operations basics

Every single article I read about Eloquent usually starts with some reading operations. I don't like it. I will teach you how to create and insert new records, then we will fetch them with some reading operations.

No boring test inserts with some external administration tool.

Creating operations

Let's create our first book! As a reference for the record structure, we will use the books table that we created in the previous chapter. The table has a very simple structure: a title, page count (pages_count), price, and description.

The procedure is as easy as creating an object.

Well, actually it is exactly the same. Create a new GET route in routes.php file under app/Http/, named book_create and type ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required