jeudi 31 mars 2016

Laravel 5.1 - Save in one timezone, display in another

I'm using Laravel 5.1 and I need everything in my database to be in UTC format. But when displaying the data it has to be in timezone 'Europe/Ljubljana' (also display needs to change depending on DST).

The app is already quite large so I want to change it on as few places as possible. What would be the best way for doing this?

What I thought of so far was either extending the model class and setting accessors/mutators (I have to change it in all x Models then) for created_at/updated_at or simply creating a trait for those accessors/mutators and putting it in all models.

But the problem with this is that some models have more than just created_at/updated_at and I need to add those mutators/accessors manually then for each model.

Is there any better way? And if not, does it make sense to make a trait or is it better to create some type of master model and extend it everywhere?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire