-
PackageOther Package Versionv3.2 How can we help you?Hi. Is there a way to override query separately for form and table. I know about UPD: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
Is it a relationship? Provide more info.. |
Beta Was this translation helpful? Give feedback.
-
|
I found the solution for my case. In Resource class I can override the 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::getEloquentQuery()->first();
}or I can just override public static function resolveRecordRouteBinding(int | string $key): ?Model
{
return app(static::getModel())
->resolveRouteBindingQuery(static::getEloquentQuery(), $key, '<recordTable>.id')
->first();
} |
Beta Was this translation helpful? Give feedback.
-
|
@IVoyt You can also set the protected static ?string $recordRouteKeyName = '<recordTable>.id'; |
Beta Was this translation helpful? Give feedback.
I found the solution for my case. In Resource class I can override the
resolveRecordRouteBindingmethod where the ambiguous id is set.So now I can specify
wherecondition for requested resource id ingetEloquentQuerymethod and inherit it's query inresolveRecordRouteBinding