K
K
kupurim2018-07-02 11:56:13
Laravel
kupurim, 2018-07-02 11:56:13

How in Laravel column values ​​as column name?

Hello.
It is necessary to output records according to the following principle.
There is a result column and it stores the names of other columns - column_1, column_2, column_3.
We need records where result contains one of the tables column_1 (or column_2 or column_3, that is, any column names) and the value in it is zero.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yan-s, 2018-07-02
@Yan-s

What is the rationale for such an approach? This suggests a relationship through a many-to-many table, rather than storing a list in result.
And apparently the table with columns is designed incorrectly. What you place in column_1, column_2, ... should most likely be moved to a separate table, where the column names become values.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question