Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Jul 23, 2023
1 parent e3c7083 commit e2125b9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/Nova/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ public function fields(NovaRequest $request)
}),
])
)->filterable()
->dontReorderAttachables()
->allowDuplicateRelations(),
];
}
Expand Down Expand Up @@ -310,6 +311,25 @@ public function filters(NovaRequest $request)
];
}

/**
* Build a "relatable" query for the given resource.
*
* This query determines which instances of the model may be attached to other resources.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Laravel\Nova\Fields\Field $field
* @return \Illuminate\Database\Eloquent\Builder
*/
public static function relatableBooks(NovaRequest $request, $query, $field)
{
if ($field instanceof BelongsToMany && in_array($field->attribute, ['giftBooks'])) {
return $query->reorder()->orderBy('sku', 'desc');
}

return $query;
}

/**
* Return the location to redirect the user after creation.
*
Expand Down

0 comments on commit e2125b9

Please sign in to comment.