E
E
ettychel2019-07-03 09:28:34
Laravel
ettychel, 2019-07-03 09:28:34

How to return an array in which one of the elements is the result of view()?

Good morning everyone, and maybe not good after reading the question)
I know what I'm doing is fundamentally wrong, but now there is no time to do it normally from the word at all.
Question: there is a controller to which it throws an ajax request, the controller fulfills the view and throws back the finished html, but when I send not only html, but an array of html and some variable, then instead of html comes emptiness, and the second variable is normal, actually how to send an array with such data?
In the end, I just need to send two different pieces of
html

$items[$table] = view('worktable.w_dop_table', ['items' => $items[$table], 'table' => $table]);
return $items[$table];

Here is what I would like:
$items['li'] = view('li_for_table',['items' => $items[$table], 'table' => $table]);
$items[$table] = view('worktable.w_dop_table', ['items' => $items[$table], 'table' => $table]);
return $items;

To everyone who kicks for such sadism, thank you)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
ettychel, 2019-07-03
@ettychel

Answer to my question found

$view = [
          'li' => view('li_for_table',['items' => $items[$table], 'table' => $table])->render(),
          'table' => view('worktable.w_dop_table', ['items' => $items[$table], 'table' => $table])->render()
    ];
return $view;

K
kafkiansky, 2019-07-03
@mad_maximus

$view = [
          'li' => view('li_for_table',['items' => $items[$table], 'table' => $table]);,
          'table' => view('worktable.w_dop_table', ['items' => $items[$table], 'table' => $table]);
    ];
return new Response($view);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question