T
T
turindd2021-09-04 08:51:21
Laravel
turindd, 2021-09-04 08:51:21

How to include php file in controller?

Hello. Please tell me how to connect php file in the controller?
Thanks in advance to everyone!

there is a file that lies app/dictionary/en.php
in the database, I write down the numbers, and in the file I store the values ​​and keys in arrays.

$lg_day_week = array (
    1 => 'пн',
    2 => 'вт',
    3 => 'ср',
    4 => 'чт',
    5 => 'пт',
    6 => 'сб',
    7 => 'вс',);
$lg_color = [
    1 =>  [ 'color'=>'#000',     'checkbox_white'=>1,],  // черный
    2 =>  [ 'color'=>'#888',     'checkbox_white'=>0,],  // серый
    3 =>  [ 'color'=>'#ccc',     'checkbox_white'=>0,],  // серебристый
    4 =>  [ 'color'=>'#fff',     'checkbox_white'=>0,],  // белый
    5 =>  [ 'color'=>'#f3e6c6',  'checkbox_white'=>0,],  // бежевый
    6 =>  [ 'color'=>'#ff0000',  'checkbox_white'=>1,],  // красный
    7 =>  [ 'color'=>'#ce6700',  'checkbox_white'=>1,],  // коричневый
    8 =>  [ 'color'=>'#ffa500',  'checkbox_white'=>0,],  // оранжевый
    9 =>  [ 'color'=>'#ffd807',  'checkbox_white'=>0,],  // золотистый
    10 => [ 'color'=>'#fff700',  'checkbox_white'=>0,],  // желтый
    11 => [ 'color'=>'#008000',  'checkbox_white'=>1,],  // зеленый
    12 => [ 'color'=>'#42aaff',  'checkbox_white'=>0,],  // голубой
    13 => [ 'color'=>'#0000ff',  'checkbox_white'=>1,],  // синий
    14 => [ 'color'=>'#8b00ff',  'checkbox_white'=>1,],  // фиолетовый
    15 => [ 'color'=>'#fc0fc0',  'checkbox_white'=>0,],  // розовый
    16 => [ 'color'=>'#fff',     'checkbox_white'=>0,],  // бесцветный
];

1. in the blade I connect
<?php include app_path() . '/dictionary/ru.php'; ?>

2. but it does not work in the controller, how can I connect it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
inFureal, 2021-09-04
@turindd

Create a separate file in config and use.
config('cusom.lg_color.1')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question