Search code examples
laravelviewmappingaliases

Laravel : set aliases for column's values


I'd try to ask my question correctly but not sure my problem is I have a static values (MTB,BMX ,TRIAL,TRACK) in my databases which they are referred to a longer name as following :

               'MTB' =>   'xxxxxxxxxxxxxxxxxxxxxx',
               'BMX' =>   'yyyyyyyyyyyyyyyyyyyyyy',
               'TRIAL' => 'zzzzzzzzzzzzzzzzzzzz',
               'TRACK' => 'wwwwwwwwwwwwwwwwwwww',

I'd prefer to show them in my views with their longer name and update them with their short name . is there any good shortcut for that ? or I have to compare one by one with their values in my views then show what I wanted.


Solution

  • so, I did not received any suggestions but I tried to figure it out by creating an extra table in my DB and assign an ID for each static item and making relationship and fetching and storing by relation as following but I'm not sure this was the best solution,it does not make sense, yet.

    EVENTS Table :

       id   name          major_id  
        1   liga 1st          1     
        2   liga 2nd          2     
    

    Majors Table :

    id  symbol                 name     
    1   MTB           xxxxxxxxxxxxxxxxxxxxxxxx  
    2   ROAD          yyyyyyyyyyyyyyyyyyyyyyyy  
    3   TRACK         zzzzzzzzzzzzzzzzzzzzzzzz