In this video, learn how to save records to the database using Laravel Eloquent and its ActiveRecord system.
- [Man] Saving using Eloquent is a bit different … from how we approach finding records … for some really good reasons, … which is that Eloquent tries to be more cautious … when writing data to the database. … We'll look at the controller for bookings … to see how we approached it the first time. … Open up the controller at app, HTTP, … Controllers, BookingController.php. … In our current design in the store method, … on line 44, we basically passed in … the array of data we want to save to the database table. … Here on line 46, we basically saved … the InsertThisData from this array. … And on line 54, we repeat the same action. … We're going to approach this with a totally different approach. … First, erase lines 46 through 53. … Next, we're going to replace all that … with a single line of code. … It's going to be … our variable booking is going to be equal to: … Booking, colon colon, create, parentheses, … request, arrow, input, parentheses again. … This says to create a new instance of the booking model …
- Exploring Laravel
- Setting up simple authentication
- Controllers and routes
- Create and index view
- Show, edit, and destroy views
- Writing scopes in Laravel Eloquent
- Creating one-to-one relationships
Skill Level Beginner
MVC Frameworks for Building PHP Web Applicationswith Drew Falkman2h 57m Intermediate
Ajax with PHP: Add Dynamic Content to Websiteswith Kevin Skoglund3h 37m Intermediate
What you should know1m 52s
2. Starting Your Project
3. The Create and Index Views
4. The Show, Edit, and Destroy Views
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.