Coder Social home page Coder Social logo

Comments (7)

antonkomarev avatar antonkomarev commented on July 24, 2024

As I understand it doesn't support abstract base type at this moment.

from single-table-inheritance.

karlhepler avatar karlhepler commented on July 24, 2024

@a-komarev I'm not sure if this will help you, but after posting this message last year, I ended up writing a simplistic version myself. It's not fancy, but it worked for what I needed. https://github.com/oldtimeguitarguy/eloquent-single-table-inheritance

from single-table-inheritance.

antonkomarev avatar antonkomarev commented on July 24, 2024

Thanks for sharing your work @oldtimeguitarguy, but it doesn't work with abstract base class too :(

from single-table-inheritance.

jonspalmer avatar jonspalmer commented on July 24, 2024

@oldtimeguitarguy I'm as confused as @a-komarev as to how this is different :)

What is broken with abstract base classes? It's not an area I've explored much but it doesn't sound like it would be a terribly hard problem to fix. Do you have stack traces or failing test cases that you can attach so we can track this down?

from single-table-inheritance.

karlhepler avatar karlhepler commented on July 24, 2024

@bostanio

Itโ€™s not really that different. I was just throwing an alternative into the mix. I was pretty adamant about having an abstract base class at first, but Eloquent donโ€™t play that game. ;-)

In the end, I found the concrete base class to be more powerful anyway. You can make a request on behalf of the base class and it will return a collection of child classes, matched by their db definition.

from single-table-inheritance.

antonkomarev avatar antonkomarev commented on July 24, 2024

@bostanio you cannot instantiate abstract class. So if Base class is abstract there is no way to pass it to relation.
I think the only way to deal with it - provide factory class to relation which will decide which subclass should be instantiated.

from single-table-inheritance.

jonspalmer avatar jonspalmer commented on July 24, 2024

I'd like to be able to support it but its very painful given the Illuminate internals. The trade off isn't particularly worth it for the relatively simple cost of having non abstract classes

from single-table-inheritance.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.