Answers for "eager load relationships by default in the model laravel"

PHP
0

eager load relationships by default in the model laravel

class Post extends Model
{
    protected $with = ['category', 'author'];

    public function category()
    {
        return $this->belongsTo(Category::class);
    }

    public function author()
    {
        return $this->belongsTo(User::class, 'user_id');
    }
}
Posted by: Guest on January-11-2022

Code answers related to "eager load relationships by default in the model laravel"

Browse Popular Code Answers by Language