Skip to content
Discussion options

You must be logged in to vote

I found the solution for my case. In Resource class I can override the resolveRecordRouteBinding method where the ambiguous id is set.
So now I can specify where condition for requested resource id in getEloquentQuery method and inherit it's query in resolveRecordRouteBinding

public static function getRecordId(): null|string
{
    return Route::current()->parameter('record');
}

public static function getEloquentQuery(): Builder
{
    return self::$model::query()
        ->leftJoin('some_table', 'some_table.foreign_id', '=', 'recordTable.id')
        ->where('news_id', self::getRecordId());
}

public static function resolveRecordRouteBinding(int | string $key): ?Model
{
    return self::g…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@IVoyt
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by IVoyt
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants