Giter Site home page Giter Site logo

Comments (3)

zendzo avatar zendzo commented on August 23, 2024

i get the value of floor level by defining custom column
but it is possible if i want to access floor level through room.floor.level i think this is simpler

public static function laratablesCustomLevel($user)
    {
        return $user->room->floor->level;
    }
columns: [
                  { name: 'id' },
                  { name: 'name' },
                  { name: 'email' },
                  { name: 'action', orderable: false, searchable: false },
                  { name: 'room.name', orderable: false },
                  { name: 'level' }
              ]

from laratables.

gauravmak avatar gauravmak commented on August 23, 2024

You're right @zendzo

Nested relationships aren't supported yet.

You have used the custom column the right way but you should also tell the query to eager load data to prevent n+1 issue.

/**
 * Specify additional conditions for the query, if any.
 *
 * @param \Illuminate\Database\Eloquent\Builder
 * @param \Illuminate\Database\Eloquent\Builder
 */
public static function laratablesQueryConditions($query)
{
    return $query->with([ 'room.floor.level' ]);
}

from laratables.

gauravmak avatar gauravmak commented on August 23, 2024

As this isn't a common use case, I would prefer not to add support for now. Have already added the note in the readme.

from laratables.

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.