title: Get an attribute from one array in Mail blade Template
body: <p>I cannot access to the attribute "price" in my Mail class in Laravel. I´ve got an error </p>
  
  <p><em>Undefined index: price (View: C:\laragon\www\hr-english\resources\views\external__emails\registered-course.blade.php)</em></p>
  
  <p>I think the problem is the controller. I had to do a query to the database to check the price of the course, because in my <strong>registered_courses</strong> table I have a foreign key related to <strong>courses</strong> which return to me the title of the course and its price.</p>
  
  <p>When I got from the query those data and send the variables to the blade, it appears the error shown at the top.</p>
  
  <p>My controller</p>
  
  <pre><code>public function store(Request $request)
  {
      try {
  
          $data = $this-&gt;getData($request);
          $email = Auth::user()-&gt;email;
          $name = Auth::user(); 
          $msg = $data;
          $price = DB::table('courses')-&gt;select('price')-&gt;where('id', '=', $request['course_id'])-&gt;get();
  
          RegisteredCourse::create($data);
          Mail::to($email)-&gt;queue(new RegistCourse($msg, $email, $name, $price));
  
          return redirect()-&gt;route('registeredCourse.index')
                           -&gt;with('sucess_message', 'Registered course was sucessfully added');
  
      } catch(Exception $exception) {
  
          return back()-&gt;withInput()
                       -&gt;withErrors(['unexpected_error' =&gt; 'Unexpected error occurred while trying to process your request.']);
      }
  
  }
  </code></pre>
  
  <p>My Mailable</p>
  
  <pre><code>class RegistCourse extends Mailable
  {
      use Queueable, SerializesModels;
  
      public $subject = 'Registered Course';
  
      public $msg;
      public $email;
      public $name;
      public $price;
  
      /**
       * Create a new message instance.
       *
       * @return void
       */
      public function __construct($msg, $email, $name, $price)
      {
          $this-&gt;msg = $msg;
          $this-&gt;email = $email;
          $this-&gt;name = $name;
          $this-&gt;price = $price;
  
      }
  
      /**
       * Build the message.
       *
       * @return $this
       */
      public function build()
      {
          return $this-&gt;view('external__emails.registered-course');
      }
  }
  </code></pre>
  
  <p>This is my blade template</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;body&gt;
      &lt;div class="container"&gt;
          &lt;div class="row"&gt;
              &lt;div&gt;
                  &lt;img src="{{asset('images/logo_leon.png')}}" alt="logo_leon" width="55" id="logo_login"&gt;&lt;span style="color:gray"&gt;HOLYROOD ENGLISH SCHOOL&lt;/span&gt;
              &lt;/div&gt;
              &lt;br&gt;
              &lt;div&gt;
                  &lt;p&gt;Thank you very much for your purchase, {{$name['name']}}. You have just registered in one of our courses.&lt;/p&gt;
                  &lt;p&gt;
                     
                      &lt;table&gt;
                          &lt;tr&gt;
                              &lt;th&gt;Name&lt;/th&gt;
                              &lt;th&gt;Course&lt;/th&gt;
                              &lt;th&gt;Date of purchase&lt;/th&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                          &lt;td&gt;{{$msg['course_id']}}&lt;/td&gt;
                          &lt;td&gt;{{$price['price']}}&lt;/td&gt;
                          &lt;/tr&gt;
                          
                      &lt;/table&gt;
                      
                      &lt;/p&gt;   
                  &lt;/p&gt;
                  &lt;p&gt;See you in class. Surely we enjoy learning English.&lt;/p&gt;
                  &lt;p&gt;If you have any questions, do not hesitate to contact us through any of our contact forms.&lt;/p&gt;
                  &lt;br&gt;
                  &lt;p&gt;Equipo Holyrood English School&lt;/p&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><a href="https://i.stack.imgur.com/gOte6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gOte6.png" alt="enter image description here"></a></p>