I have a table on my DB with these columnns:
+-----------------+---------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+---------------------+------+-----+---------+----------------+
| id | bigint(20) unsigned | NO | PRI | NULL | auto_increment |
| name | varchar(255) | NO | | NULL | |
| value | varchar(255) | NO | | NULL | |
+-----------------+---------------------+------+-----+---------+----------------+
I would access to value values by name.
For example I have these datas:
+----+------------+------------+
| id | name | value |
+----+------------+------------+
| 1 | start_date | 2020-01-01 |
| 2 | end_date | 2021-01-01 |
+----+------------+------------+
I would to get '2020-01-01' by 'start_date'.
I tried this code, but I'm not satisfyed because with this code I get all values of the row, not only the value expected.
Configuration::get()->keyBy('start_date');
I'm not sure I was clear.
Let me know.
Thanks a lot!!
Configuration::pluck('name', 'value')might work (or::pluck('value', 'name'), not sure on the order)['start_date' => '2020-01-01', 'end_date' => '2021-01-01'], so if you did$keyVals = Configuration::pluck('value', 'name');, then you'd be able to access it like$keyVals['start_date']('2020-01-01') and$keyVals['end_date']('2021-01-01'). Is that what you're looking for? If not, then I really don't understand your question...