Glossary

Model

In Laravel, a PHP class that stands for one database table, so your code can read and save rows as objects.

In plain words

Think of a library card catalogue: each card describes one book, and the librarian uses the cards to find and update books. A model is that card system for one table. The Lesson model stands for the lessons table; one Lesson object is one row.

In Laravel

Create one with php artisan make:model Lesson -m (the -m also creates a migration). Then Lesson::create([...]) saves a row and Lesson::query()->latest()->get() reads rows, without writing SQL by hand. The $fillable list says which columns may be filled from a request.

See Build a REST API.

Found this useful?

Every lesson stays free. Tap the thumbs up so we know what works, or say thanks with a soda or a coffee: it pays for hosting and new lessons.

Buy me a sodaBuy me a coffee

Want more on this?

Tell us which part was not clear, ask for a follow-up lesson, or request a lesson on any topic. We read every request.

I would like
Only to tell you when it is ready.

WhatsApp

Join the channelChat with us

Free lessons and updates in the channel. Questions about learning or training? Chat with us.