© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
4 replies
Vulture

Ambiguous "id" column on Edit Page

Hello, i have a custom query on resource, my problem on edit page, two table with inner joined,
both table have "id" column, edit page add "WHERE" query on "id" column, this is causing the error.

How to change "WHERE id" to "WHERE users.id" ?

    public static function getEloquentQuery(): Builder
    {
        $authUser = Auth::guard('admin')->user();
        //$branch = Branch::where('corp_id',$authUser->corp_id)->first();

        if ($authUser->is_owner) {
            // NOTE : Inner join bug on this line
            return static::getModel()::query()
            ->select('branches.id AS branch_id','branches.title AS branch_title','users.*')
            ->join('branches', 'branches.id', '=', 'users.branch_id')
            ->where('corp_id',$authUser->corp_id);
        }

        return static::getModel()::query()->where('branch_id',3);
    }
    public static function getEloquentQuery(): Builder
    {
        $authUser = Auth::guard('admin')->user();
        //$branch = Branch::where('corp_id',$authUser->corp_id)->first();

        if ($authUser->is_owner) {
            // NOTE : Inner join bug on this line
            return static::getModel()::query()
            ->select('branches.id AS branch_id','branches.title AS branch_title','users.*')
            ->join('branches', 'branches.id', '=', 'users.branch_id')
            ->where('corp_id',$authUser->corp_id);
        }

        return static::getModel()::query()->where('branch_id',3);
    }
testphoto.png
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

ambiguous column name: id
FilamentFFilament / ❓┊help
2y ago
Column 'id' in where clause is ambiguous in edit record page
FilamentFFilament / ❓┊help
2y ago
Avoid ID in edit page
FilamentFFilament / ❓┊help
16mo ago
RelationManager belongsToMany withPivot(['id']) returns Column 'id' in order clause is ambiguous
FilamentFFilament / ❓┊help
2y ago