Post model with title and body in laravel 8

Created 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

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.