Support the ongoing development of Laravel.io →
posted 9 years ago
Eloquent
Last updated 1 year ago.
0
Solution

why not using jsut one model for cellphone and laptop and have a type_id property to distinguish between those? i think you'd be off the best with that.

you could then even create a method on the model or using a respository to get cellphones or laptops only.(Item::whereTypeId(Item::$TYPES->CELLPHONE)->get())

Last updated 1 year ago.
0

Try looking int single-table-inheritance - basically you define an abstract parent class and extend it with some specific subclasses that can encapsulate their unique attributes.

http://laravel.io/forum/02-17-2014-eloquent-single-table-inher...

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.