Backend Development Laravel Subjective
Sep 30, 2025

Explain Laravel's MVC architecture and how it works.

Detailed Explanation
Laravel follows the MVC (Model-View-Controller) pattern: **Model**: Represents data and business logic. Uses Eloquent ORM.
class User extends Model {
    protected $fillable = ["name", "email"];
    
    public function posts() {
        return $this->hasMany(Post::class);
    }
}
**View**: Presentation layer using Blade templates.

@foreach($users as $user)
    

{{ $user->name }}

{{ $user->email }}

@endforeach
**Controller**: Handles HTTP requests and coordinates between Model and View.
class UserController extends Controller {
    public function index() {
        $users = User::all();
        return view("users.index", compact("users"));
    }
}
Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback