title: Two few arguments passed to public function constructor PHP
body: <p><strong>mailService.php</strong></p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  
  namespace App\Http\Services;
  
  use Illuminate\Bus\Queueable;
  use Illuminate\Mail\Mailable;
  use Illuminate\Queue\SerializesModels;
  use Illuminate\Contracts\Queue\ShouldQueue;
  
  class mailService extends Mailable
  {
      use Queueable, SerializesModels;
      /**
       * The data instance.
       *
       * @param $data
       */
  
      public $data;
  
      /**
       * Create a new message instance.
       *
       * @return void
       */
  
      public function __construct($data)
      {
          $this-&gt;data = $data;
      }
  
      public function build()
      {
          $address = 'janeexampexample@example.com';
          $subject = 'This is a demo!';
          $name = 'Jane Doe';
  
          return $this-&gt;view('emails.test')
                      -&gt;from($address, $name)
                      -&gt;cc($address, $name)
                      -&gt;bcc($address, $name)
                      -&gt;replyTo($address, $name)
                      -&gt;subject($subject)
                      -&gt;with([ 'test_message' =&gt; $this-&gt;data['message'] ]);
      }
  } 
  </code></pre>
  
  <p><strong>clientService.php</strong></p>
  
  <pre class="lang-php prettyprint-override"><code>use App\Http\Services\mailService as EmailService;
  /**
  * @param $clientId
  * @param $comp_id
  *
  * @return \App\Http\Models\clients|\Illuminate\Database\Eloquent\Model
  */
  public function getClient($clientId, $comp_id)
  {
      $data = ['message' =&gt; 'This is a test!'];
  
      Mail::to('test@test.com')-&gt;send(new EmailService($data));
  
      return $this-&gt;clientsRepository-&gt;getClient($clientId, $comp_id);
  }
  </code></pre>
  
  <p>When I pass the argument <code>$data</code> to a new instance of <code>EmailService</code> I get an error saying </p>
  
  <blockquote>
    <p>too few arguments passed to constructor function</p>
  </blockquote>
  
  <p>but I don't understand why if I'm passing <code>$data</code> in the <code>clientService</code>, thank you for your help in advance. </p>
  
  <p>I'm using the Lumen Framework <code>5.3</code> and PHP <code>7.2</code> and this code sample was taken from <a href="https://sendgrid.com/docs/for-developers/sending-email/laravel/" rel="nofollow noreferrer">Sendgrid docs</a>.</p>