E
E
Evgeniy2019-04-08 17:07:40
Laravel
Evgeniy, 2019-04-08 17:07:40

What are the ways to store infrequently changing data of different types in Laravel?

I am developing a website in Laravel.
There are various data that are used in many places. For example, a company phone number, or some kind of array.
Occasionally, this data will need to be changed.
Where is all this stored?
What is considered the best way in Laravel?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
J
JhaoDa, 2019-04-08
@JhaoDa

If it's rare it's once a year or there is someone who can do it:
If more often or it is a pity to pay someone who can do it:
+ and minimal binding for editing

D
Danny Chase, 2019-04-08
@Dase23

You won’t believe it)
In the DB) array, of course, it’s better not to hard code, but to collect from the same database.
But if it’s too tight, go to redis

A
Alex Wells, 2019-04-08
@Alex_Wells

IMHO:
- some technical variables, or those that the customer did not want to edit simply and conveniently (well, he changes them once a year - you can ask a programmer) - as JhaoDa said - in .env and configs.
- non-technical variables, or those that the customer wished to edit simply and conveniently - in hocon/toml/yaml (or similar languages) files. All of them have a syntax that the customer can handle, as well as ready-made parsers. Absolutely utopia - automatically mapit them into the objects of the development language, with the help of some annotations or other instructions.

J
jazzus, 2019-04-08
@jazzus

As for the company's phone or some array.
You create a company.php file in the config folder
and write it there

/*
    |--------------------------------------------------------------------------
    | Телефон
    |--------------------------------------------------------------------------
    */
    'phone' => 5555555,
    /*
    |--------------------------------------------------------------------------
    | массив данных
    |--------------------------------------------------------------------------
    */
    'array' => [
        'title' => value,
        'title2' => value2,
    ],

Get data in controller
$phone = config('company.phone');
$array = config('company.array');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question