jeudi 25 janvier 2018

Laravel-translatable Best way to select only specific attributes

For example, I have Country model with attributes:

  • id
  • name (varchar 255)
  • short_description (varchar 255)
  • description (large text 5000+ symbols)
  • additional_description (one more very large text)

I don't want to load and return to user large texts from description and additional description when user only browses a list of countries. So what is the best way to show only id, name and short_description in collection (array) but still load all the fields for a single resource?

I expected something like: PHP Country::withTranslation()->get(["id", "name", "short_description"]); or PHP Country::listsTranslations("name", "short_description");



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire