Lesson list · Lesson 5 of 5
The Basics · Lesson 5 of 5
Working with the Database
Describe your tables with migrations, then read and write rows with Eloquent.
1 min 0 comments
A migration describes a table in PHP, so the whole team gets the same database structure.
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->text('body');
$table->timestamps();
});Reading and writing
With the table in place, Post::create() saves a row and Post::latest()->get() reads them back, newest first. No SQL needed for everyday work.
Discussion
Log in to join the conversation. Log in
No discussion here yet. Be the first to ask.