Post model with title and body in laravel 8

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

Answers 1
  • 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'
        ];
    }
    
    0
  • Back to code snippet queries related laravel