MVC Principle


  • Model:

    Stores data from the database
  • View:

    Manages templates
    Handles HTML output
  • Controller:

    Controls the application

MVC in Laravel

Model

<?php
  namespace App\Models;
  use Illuminate\Database\Eloquent\Factories\HasFactory;
  use Illuminate\Database\Eloquent\Model;

  class User extends Model
  {
     use HasFactory;
  }
?>

View

<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Laravel</title>
</head>
<body>
  
    @section('screen')
    @show
  
</body>
</html>

Controller

<?php
  namespace App\Http\controllers;
  use App\Http\Controllers\Controller;
  use Illuminate\Http\Request;

  class UserController extends Controller
  {
     //
  }
?>