Code Monkey home page Code Monkey logo

Comments (7)

cviebrock avatar cviebrock commented on June 8, 2024

Hmm ... the solution is probably for the package to ignore the $with relationships entirely, when making that query.

I'm not at a place where I can test currently, but can you try changing that block to something like:

$results = $query->without([])
    ->select([$attribute, $this->model->getQualifiedKeyName()])
    ->get()
    ->toBase();

I'm not sure if the without([]) is the correct syntax to ignore all eager loading relations, so that might need tweaking.

Thanks!

from eloquent-sluggable.

ryanpitts1 avatar ryanpitts1 commented on June 8, 2024

I haven't been able to try that yet. I did see a possible withoutRelations() method for models but might not be what is needed.

Eliminating the ->select([$attribute, $this->model->getQualifiedKeyName()]) would of course solve it but I assume this is in the package to keep memory consumption down?

I'll see if I can test it tomorrow. For now, I removed my eager loading $with and it worked.

from eloquent-sluggable.

ryanpitts1 avatar ryanpitts1 commented on June 8, 2024

Was actually able to test it just now.

Adding ->without([]) didn't work, but using ->without(['role']) did work. Working code:

$results = $query->without(['role'])
            ->select([$attribute, $this->model->getQualifiedKeyName()])
            ->get()
            ->toBase();

Maybe there's a way to make that manageable through the array in sluggable() method that also handles the slug source?

from eloquent-sluggable.

cviebrock avatar cviebrock commented on June 8, 2024

->withoutEagerLoads() should do it, I'd think.

from eloquent-sluggable.

ryanpitts1 avatar ryanpitts1 commented on June 8, 2024

@cviebrock that seems to have done the trick!

As a side note: I also discovered that I only get the error when I have this turned on Model::shouldBeStrict() in my AppServiceProvider

from eloquent-sluggable.

cviebrock avatar cviebrock commented on June 8, 2024

So, I was trying to make a failing test for this before adding the fix ... but I can't seem to make one. I'm not sure if it's related to the strict mode setting you had, or something else ... but I'm not sure.

If you have some time, would you mind pulling down the issue605 branch of this package and building and testing it on your set up?

from eloquent-sluggable.

ryanpitts1 avatar ryanpitts1 commented on June 8, 2024

Thanks! I'll give this a try this weekend. I believe it is related to the Model::shouldBeStrict() setting. I only see it when I have the strict mode turned on. I believe that is because the MissingAttributeException exception only appears when strict mode is on - otherwise, Laravel just stays quiet when trying to access missing attributes.

from eloquent-sluggable.

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.