Post model with title and body in laravel 8

Updated at 06-Sep-2021, By samar

Post model with title and body in laravel 8

In this tutorial, we will try to find the solution to "Post model with title and body in laravel 8" through programming.

Here we provide post model with protected $table attribute and protected $fillable attribute with title and body field in laravel
  • Post model with title and body

    --PATH app\Models\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";
        protected $fillable = [
            'title', 'body'
        ];
    }
    

Back to code snippet queries related laravel