MVC Pattern

See how Model, View, and Controller work together

MVC separates your app into Model, View, and Controller. Step through the flow to see how data moves.

The user interacts with the View (a Blade template form).

Model

class Post extends Model {
  protected $fillable =
    ['title', 'body'];
}

View

@foreach($posts as $post)
  <h2>{{ $post->title }}</h2>
@endforeach

Controller

public function index() {
  $posts = Post::all();
  return view('posts.index',
    compact('posts'));
}