M
M
miniven2016-03-25 13:17:54
HTML
miniven, 2016-03-25 13:17:54

Why doesn't @foreach work in laravel?

I want that after filling out the application on the site, the entered values ​​​​will come to my mail.
In the controller, I indicated that, in $message, everything that the user entered will be recorded:

public function call(Request $request) {
        $message = $request->All();

        Mail::send('pages._partials.email', $message, function($message) {
            $message->to('[email protected]', 'mail')->subject('Заявка с сайта');
        });

        return redirect()->route('pages.index');
    }

And then in the template I specify that I need to walk through the object and display the values:
@extends('layouts.master')

@section('content')
  <h2>Заявка с сайта</h2>

  @foreach ($message as $key => $value)
    <p>{{ $key }} and {{ $value }}</p>
  @endforeach
@stop

Why aren't the values ​​displayed? Even if I use foreach and display just some text every time, nothing that was inside the foreach is still sent to the mail .

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Osher, 2016-03-25
@miniven

Mail::send('pages._partials.email', compact('message'), function($message) {
            $message->to('[email protected]', 'mail')->subject('Заявка с сайта');
        });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question