Giter VIP home page Giter VIP logo

Comments (6)

sptdigital avatar sptdigital commented on September 24, 2024 2

Here's how I got around this issue ....

if(Input::has('relatedModelsField')) {
            $relatedModelsField= Input::get('relatedModelsField');
            $model = Model::whereHas('relatedModel', function ($query) use ($relatedModelsField) {
                $query->where('relatedModelsField', '=', $relatedModelsField);
            });
        } else {
            $model= new Model();
        }

        $builder = ApiHandler::parseMultiple($model, array(), Input::except('relatedModelsField'))->getBuilder();

from laravel-api-handler.

marcelgwerder avatar marcelgwerder commented on September 24, 2024

Right now unfortunately not. This is a feature I would like to have too though. However there are some problems respectively open questions.

  • I think having dots in a parameter name causes problems so we would need a replacement.
  • We can't filter the parent table the way Eloquent attaches relationships. We would for example need to attach a join for each filter param.
  • If we query the relationship with with it would also make sense if the filter only filters this list instead of defining if the parent is in the result or not. Both with the same param won't work of course.

Maybe you have a suggestion for e clean implementation. Would be happy to hear it. I unfortunately right now don't have the time.

from laravel-api-handler.

sptdigital avatar sptdigital commented on September 24, 2024

For the issue with dot's in the name, it is worth reading this thread.

Has there been any changes to the way relationships are handled in Eloquent, or are they still done in a similar way?

from laravel-api-handler.

sptdigital avatar sptdigital commented on September 24, 2024

Having created a workaround for the aforementioned issue, the final query is missing the join for any tables defined in the '_with'.

i.e.
my.api/someobject/?_with=contract&contract.contractnumber-lk=1234 will report something along the lines of 'unknown field contract.contractnumber on table someobject'.

The _with is getting parsed, but is not getting used.

from laravel-api-handler.

Pederytter avatar Pederytter commented on September 24, 2024

Yeah I'm having the same problem. A patch for this to work would be awesome.

from laravel-api-handler.

scheMeZa avatar scheMeZa commented on September 24, 2024

Would love to see this

from laravel-api-handler.

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.