M
M
Max Conner2020-06-12 14:43:09
Laravel
Max Conner, 2020-06-12 14:43:09

How to compare the field data in db and the value passed through request, if the field value is formed in the model?

There is a name column in the DB whose value is int().
In model I form constants.

const NAME = 1;
    const CAR = 2;
    const TR = 3;
    const PROVIDER = 4;
    const CLIENT = 5;


And I write their values ​​​​in the given field name.

Later I assign the const value through self::NAME => 'technique' and so on for all const.
return [
            self::NAME => 'техника',
            self::CAR => 'авто',
            self::TR => 'терминал',
            self::PROVIDER => 'интернет',
            self::CLIENT => 'клиент',
        ];

On the output page, this name field displays exactly the assigned values ​​through self::
The question is as follows: On the output page, there is a search field in which a value is entered, constants self::NAME => 'technique'.
How to compare the data received via request with the data of the name field in the DB, so that at the output we get exactly those records that have the value of the selected constant in the name field?
I use Laravel 7.
Thanks in advance for the answers and hints

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vism, 2020-06-12
@cdcdcd

You can paraphrase it like I run a marathon after I shoot myself in the foot.
These constants are an ordinary dictionary. Create a table in the database, a model for this dictionary and pull out the links. Search by request.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question