mercredi 23 janvier 2019

Store static array used by a number of models

I have an application written in Laravel 5. I have a model Product which uses a table products.

In the table I want to store the product size. At the moment there are only two sizes: M and L which stand for Medium and Large.

An admin user is able to update the size so I will have a dropdown for this. My question is; what is the best way to store the size data?

  1. Add static array the Product Model
  2. Create a Size Model with database with a relationship
  3. Create a Size Model with no database but a static array
  4. Add the array to config file

It is possible that more sizes will be introduced and that other models will use them. I'm thinking it's fine to just add as a static array to the Product model.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire