title: Eloquent 5.7: Creation-Event
body: <p>I would like to automate the allocation of data to a property (i.e. customized ID-number) as soon as a new item has been created.</p>
  
  <p>I understood that the example given in the next box is unfortunally not possible anymore with Eloquent 5.7!</p>
  
  <p><strong>Not possible in Eloquent 5.7:</strong></p>
  
  <pre><code>use Illuminate\Database\Eloquent\Model as Eloquent;
  
  class Message extends Eloquent {
      ...
      public static function boot() {
          parent::boot();
  
          self::creating(function ($model) {
              $model-&gt;ID = 1234; // 1234 shall be replaced later by a function
          });
      }
      ...
  }
  </code></pre>
  
  <p><strong>For Eloquent 5.7:</strong></p>
  
  <p>As far as I understood, I have to define now a seperate class and link it in my model to the requested event like this:</p>
  
  <pre><code>use Illuminate\Database\Eloquent\Model as Eloquent;
  
  class Message extends Eloquent {
      ...
      protected $dispatchesEvents = [
          'creating' =&gt; MessageCreated::class,
      ];
      ...
  }
  </code></pre>
  
  <p>But my problem is now, that I don't know how I create this extra class "MessageCreated". All the tutorial I have read and seen is using the full set of Laravel (doing some terminal comands with ARTISAN ...). But in my envoirement I have only Illuminate/Eloquent installed, so I have no idea how to proceed.</p>
  
  <p>Thanks for ideas!</p>
  
  <p>Tim</p>