It depends, if it is for a single model, and single action. then I'd probably stick it in the model. IF it on the other hand is something that for example handles different models, but with similar functionality in multiple methods, then I'd create a service class, and inject it.
This service class converts a text to a primary key, depending on the model.
https://github.com/Tray2/mediabase/blob/main/app/Services/ForeignKeyService.php
And this is an example where it's used.
https://github.com/Tray2/mediabase/blob/main/app/Http/Controllers/Books/BooksStoreController.php