dimanche 13 mars 2016

trying to pass data to the view laravel 5.1

here i have the following in my controller

    $data = [];

    mt_srand((double)microtime()*15000);//optional for php 4.2.0 and up.
    $charid = strtoupper(md5(uniqid(rand(), true)));
    $uuid = substr($charid, 0, 8)
    .substr($charid, 8, 4)
    .substr($charid,12, 4)
    .substr($charid,16, 4)
    .substr($charid,20,12);

    $data['confirmation_link'] = $uuid;
    //dd($data);
    Mail::send('email.test', $data, function ($m) {
        $m->from('test@test.com', 'Your Application');
        $m->to('test@gmail.com')->subject('Your Reminder!');
    });

here is my view

<p>
  This is a test, an email test.
</p>
<p>
  The variable <code>$data['confirmation_link']</code> contains the value:
</p>
<ul>
  <li><strong>{{ $data['confirmation_link'] }}</strong></li>
</ul>
<hr>
<p>
  That is all.
</p>

but i am getting the error message

Undefined variable: data 

Am i not properly passing data to the view? I am passing an array. Im still a kinda new to MVC frameworks and working with OOP.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire