Hi !
My question is about where to place some piece of code. I use Intervention Image to handle my images. I have 4 models that use images (user, post, tag and category). I encode the filename so I have some utilities fonctions that let me get, delete and resize images. For the moment I have put them inside a class ImageHelper inside my app/lib forlder, that only contain static method. All the methods need at some point to call the Intervention Image package. So my HelperImages just add a layer to Intervention Image to fit my needs.
Bu I don't think it's a good practice so I would like to know where to put it and if I should use it in an other way, like an Interface or whatever. I don't want to put all the methods in the BaseModel that is extended by all my models because others don't need all that images stuff, and it's not realy relevant. So how would you structure that ?
Thanks
I do everything you mentioned exactly the same way....Intervention with a helper in app/library. I'm not sure there's a better way, but I'm interested if there is.
If you want to share code on several models you could use a trait.
Never saw this... If you use Traits you store them in a namespace in like Acme/traits/images.php ? Or maybe you have in mind a project on GitHub that use tratis in a similar case so I look at their implementation of it.
Thanks
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community