lundi 27 juin 2016

Language implementation in Database: Laravel 5.2

What Am I doing?

I was using lang folder to maintain the translation for two languages. Now, as per the requirement, admin can also do the Language Key values changes. So, now I have moved it to database.

ok, Now my array is like below.

Collection {#191 ▼
  #items: array:6 [▼
    0 => TranslationModel {#192 ▼
      +table: "tbltranslation"
      +primaryKey: "TranslationID"
      +timestamps: true
      #connection: null
      #perPage: 15
      +incrementing: true
      #attributes: array:7 [▼
        "TranslationID" => 1
        "PageID" => 1
        "LanguageID" => 1
        "KeyID" => 1
        "Val" => "All Roles"
        "created_at" => "2016-06-27 21:37:06"
        "updated_at" => "2016-06-27 21:37:06"
      ]
      #original: array:7 [▶]
      #relations: []
      #guarded: array:1 [▶]
      #morphClass: null
      +exists: true
      +wasRecentlyCreated: false
    }
    1 => TranslationModel {#193 ▶}
    2 => TranslationModel {#194 ▶}
    3 => TranslationModel {#195 ▶}
    4 => TranslationModel {#196 ▶}
    5 => TranslationModel {#197 ▶}
  ]
}

There are 6 places in the blade where I have to show Translation from above array. I am thinking to write below code at each place inside blade.

Below is for first place.

$Translation_Dictionary->where('KeyID', 1)->first()

Am I doing it correctly?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire