aishazafar
aishazafar

Reputation: 1110

Extending one model with another model in 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.

Upvotes: 0

Views: 1038

Answers (1)

Gabriel
Gabriel

Reputation: 970

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

Upvotes: 1

Related Questions