简体   繁体   中英

How can I get the information from the array to be properly displayed (Laravel)?

Hello I have this code.

I want to send this informations from the array to the page of the email.

public function store(Request $request)
{
    $equipment=new equipment();
    $equipment -> name = request ('name');
    $equipment -> email = request ('email');
    $equipment -> department = request('department');
    $equipment -> material= request('material');
    $equipment -> finalidade = request('finalidade');
    $equipment -> till = request('till');
    $equipment -> until = request('until');
    $equipment->save();

    $data = [
        'name' => request ('name'),
        'email' => request ('email'),
        'department' => request ('department'), 
        'material' => request('material'),
        'finalidade' => request('finalidade'),
        'till' => request('till'),
        'until' => request('until')
    ];

    Mail::send('mail.newRequest',$data,function($m) use ($data){
        $m->from('myemail@gmail.com','MECTS.SA');
        $m->to('emaila@gmail.com');
        $m->subject('Requisição do colaborador '.$data['name'].' do departamento de '.$data['department']);
        $m->cc($data['email']);
    });
   
    return redirect()->route('thk');
}

This is where I create and pass the array.

Now this is the view where I want to display the data:

<td style="padding:10px;font-size:14px; width:100%;">
    <p>Nova requisição no sistema</p>
    <p>O Colaborador:$data['name']</p>
    <p><br /> Solicita: $data['material'] </p>
    <p> Por um período de:$data['till'] até:$data['untill']</p>
    <p><i>Best Regars!</i><br>
    <!-- /Callout Panel -->
    <!-- FOOTER -->
</td>

The information from the array will not be displayed (I get like O Colaborador:$data['name'] ), please help.

You do not do anything to actually display your passed data.

<p>O Colaborador:{{ $name }}</p>

https://laravel.com/docs/7.x/blade#displaying-data

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM