Skip to main contentNedix.io

MVC

Model

app/Models/Post.php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
protected $fillable = [
'title',
'content'

Route

routes/web.php
use App\Http\Controllers\PostController;
Route::resource('posts', [PostController::class, 'index']);

Controller

app/Http/Controllers/PostController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Post;
class PostController extends Controller
{

View

resources/views/posts/show.blade.php
<!DOCTYPE html>
<html>
<head>
<title>{{ $post->title }}</title>
</head>
<body>
@include('template.partials.header')
<div class="content">