dprntkxh703029 2018-04-11 11:02
浏览 218
已采纳

在Laravel中使用另一个模型扩展一个模型

I am pretty new to laravel and currently exploring its concepts. In some videos I saw a concept of models inheritance. I wonder if we can use models relationships in laravel 5.6 then why we need to inherit models. In which case we need to or should inherit models.

eg Base Model:

class User extends Authenticatable
{

}

eg Child Model:

Class UserTypeOne extends User()
{
}

eg Child Model2:

Class UserTypeTwo extends User
{
}

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • drug95107 2018-04-11 11:12
    关注

    You don't really need to inherit Models like class inherit. You should use Eloquent Relationship instead. Prior to development, you have to do proper database designing.

    https://laravel.com/docs/5.6/eloquent-relationships

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?