Skip to content

Laravel Framework

Master Laravel Framework with 50 free flashcards. Study using spaced repetition and focus mode for effective learning in Programming.

🎓 50 cards ⏱️ ~25 min Advanced
Study Full Deck →
Share: 𝕏 Twitter LinkedIn WhatsApp

🎯 What You'll Learn

Preview Questions

12 shown

What is Laravel Eloquent ORM?

Show ▼

Eloquent is Laravel's built-in Active Record ORM. Each database table has a corresponding Model class used to interact with that table. It provides an expressive syntax for queries:
$users = User::where('active', true)->get();

How do you define a one-to-many relationship in Eloquent?

Show ▼

In the parent model, define a method returning hasMany():
public function posts() { return $this->hasMany(Post::class); }
In the child model, define the inverse with belongsTo():
public function user() { return $this->belongsTo(User::class); }

What is eager loading in Eloquent and why is it important?

Show ▼

Eager loading solves the N+1 query problem by loading relationships upfront:
$books = Book::with('author')->get();
Without it, accessing a relationship in a loop triggers a separate query per iteration, causing performance issues.

How do you create a new Eloquent model and migration together?

Show ▼

Use the Artisan command:
php artisan make:model Post -m
The -m flag generates a migration file alongside the model. You can also add -f for a factory and -s for a seeder.

What are Eloquent accessors and mutators?

Show ▼

Accessors transform attribute values when reading:
protected function firstName(): Attribute { return Attribute::make(get: fn($value) => ucfirst($value)); }
Mutators transform values when setting:
set: fn($value) => strtolower($value)

What is the purpose of Blade templates in Laravel?

Show ▼

Blade is Laravel's templating engine. It provides convenient shortcuts for PHP control structures and template inheritance:{{ $var }} — escaped output@if, @foreach — control directives@extends, @section, @yield — layout inheritance

How do you pass data to a Blade view?

Show ▼

You can pass data in several ways:return view('profile', ['user' => $user]);return view('profile')->with('user', $user);return view('profile', compact('user'));All make $user available in the template.

What is the difference between {{ }} and {!! !!} in Blade?

Show ▼

{{ $var }} applies htmlspecialchars to escape output, preventing XSS attacks.
{!! $var !!} outputs raw, unescaped HTML. Only use {!! !!} when you trust the content completely.

How do you create a Blade component?

Show ▼

Use Artisan:
php artisan make:component Alert
This creates a class at app/View/Components/Alert.php and a Blade file at resources/views/components/alert.blade.php. Use it with:
<x-alert type="error" :message="$msg" />

How do you define a basic route in Laravel?

Show ▼

Routes are defined in routes/web.php or routes/api.php:
Route::get('/welcome', function () { return view('welcome'); });
You can also point to a controller:
Route::get('/users', [UserController::class, 'index']);

What are route parameters in Laravel?

Show ▼

Route parameters capture segments of the URI:
Required: Route::get('/user/{id}', ...)
Optional: Route::get('/user/{name?}', ...)
Parameters are passed as arguments to the closure or controller method.

What is route model binding in Laravel?

Show ▼

Laravel can automatically inject model instances matching route parameters:
Route::get('/posts/{post}', function (Post $post) { return $post; });
If the type-hinted variable matches the parameter name, Laravel resolves it by primary key automatically. Use getRouteKeyName() to customize.

🎓 Start studying Laravel Framework

🎮 Study Modes Available

🔄

Flashcards

Flip to reveal

🧠

Focus Mode

Spaced repetition

Multiple Choice

Test your knowledge

⌨️

Type Answer

Active recall

📚

Learn Mode

Multi-round mastery

🎯

Match Game

Memory challenge

Related Topics in Programming

📖 Learning Resources