---
# System prepended metadata

title: Laravel 8 - Model

---

# Laravel 8 - Model

> php artisan make:model Post

**Post.php**

```
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    use HasFactory;
    protected $table = 'posts';
}

```

**PostController.php**

```
use App\Models\Post;
```
```
public function getAllPostUsingModel()
    {
        $posts = Post::all();
        return $posts;
    }
```

**web.php**

```
Route::get('/all-posts', [PostController::class, 'getAllPostUsingModel'])->name('post.getallpostusingmodel');
```