`How to make associations of this kind?
A
A
andrew-corput2018-08-06 19:33:13
Laravel
andrew-corput, 2018-08-06 19:33:13

How to make associations of this kind?

How to make so that when the value is `

{{$lot->fuel}} = 1
Displayed "petrol";
`2` - "diesel" and so on?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mShpakov, 2018-08-06
@andrew-corput

1) if there can be many such types - a table across the road
2) if there are only two - make a helper that will compare the key in the argument with the internal array and return the value

E
Evgeny Perin, 2018-08-07
@seoperin

If Lot is a separate model, then you can make an array constant there

const FUEL_TYPES= [
        1 => 'Бензин',
        2 => 'Дизель',
];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question