Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relational sorting issue #2283

Closed
vntrungld opened this issue Aug 7, 2018 · 2 comments
Closed

Relational sorting issue #2283

vntrungld opened this issue Aug 7, 2018 · 2 comments

Comments

@vntrungld
Copy link

I have 2 tables: users and activities. Both has the name field.

My grid function of ActivityController looks like this:

protected function grid()
{
    return Admin::grid(Activity::class, function (Grid $grid) {

        $grid->id('ID')->sortable();
        $grid->column('user.username', 'Owner')->sortable();
        $grid->column('name')->sortable();

        $grid->created_at();
        $grid->updated_at();
    });
}

When I sort by name it works fine
image

But when I sort by Owner the name field replaced by name of the Owner
image

Is there anyone has this problem?

@freecod
Copy link
Contributor

freecod commented Sep 29, 2018

Problem exists and from here:

$this->queries->push([

Before this code need add

            $this->queries->push([
                'method'    => 'select',
                'arguments' => [$this->model->getTable() . ".*"],
            ]);

its fix set equal fields from relation to eloquent model.

z-song added a commit that referenced this issue Oct 10, 2018
@z-song
Copy link
Owner

z-song commented Oct 10, 2018

pr merged, Thanks!

@z-song z-song closed this as completed Oct 10, 2018
never615 added a commit to never615/laravel-admin that referenced this issue Oct 18, 2018
…elop

* 'master' of github.com:z-song/laravel-admin: (119 commits)
  Change Skin url
  [fix]Fix issue z-song#2615
  Fix relation sort (issue z-song#2283)
  Apply fixes from StyleCI
  [fix]
  [fix] Add a config to control default breadcrumb
  cs fix
  Styleci fix
  Better SSL support, removed # fix z-song#1768
  Add default breadcrumb
  fix
  [fix]Use content header as page sub title
  没啥好办法,增加一个配置项
  Menu模型添加属性以防旧版本用户升级后无permission字段报错
  [fix]
  Update README.md [skip ci]
  [fix]
  Apply fixes from StyleCI
  [fix]Fix issue z-song#2581
  [refactor]
  ...

# Conflicts:
#	src/Console/InstallCommand.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants