1/15
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
Model-View-Controller. It is the architectural pattern used by Laravel to separate logic (Controller), data (Model), and display (View).
What does MVC stand for?
It handles the user's request, processes logic, retrieves data (via Models), and passes that data to the View.
Role of the Controller
It is the layer responsible for interacting directly with the database tables.
Role of the Model
app/Http/Controllers
Standard directory for Controllers
Pass an array as the second argument to the view() helper: return view('home', ['categories' => $categories]);
How to pass data from a Controller to a View
Model-View-Controller. It is the architectural pattern used by Laravel to separate logic (Controller), data (Model), and display (View).
What does MVC stand for?
php artisan make:model ModelName
Artisan command to create a Model
Query Builder (using the DB facade).
Eloquent ORM (using Models).
Two main ways to retrieve DB data in Laravel
Route::get('/', [HomeController::class, 'index']); (Uses an array with the Class and the method name).
Route syntax using a Controller
It handles the user's request, processes logic, retrieves data (via Models), and passes that data to the View.
Role of the Controller
$categories = Category::all();
Eloquent syntax to get all categories
app/Models
Standard directory for Models
@foreach($items as $item) ... @endforeach
Blade directive for looping through data
It is the layer responsible for interacting directly with the database tables.
Role of the Model
$categories = DB::table('categories')->get();
Query Builder syntax to get all categories
php artisan make:controller ControllerName
Artisan command to create a Controller