title: Attribute not saving to Model in boot method
body: <p>When creating a new model instance, the 'slug' attribute is not being saved. I checked that the <code>creating</code> event in the <code>boot</code> method is being called. However, in tinker, I can see that there is no 'slug' key in the attributes. What gives? For the life of me, I can't find my mistake.</p>
  
  <p>Tinker:</p>
  
  <pre><code>App\Models\TicketType::create(['title'=&gt;'My title']);
  
  Illuminate\Database\QueryException with message 'SQLSTATE[HY000]: General error: 1364 Field 'slug' doesn't have a default value (SQL: insert into `ticket_types` (`title`, `updated_at`, `created_at`) values (my title, 2017-11-16 08:13:17, 2017-11-16 08:13:17))'
  </code></pre>
  
  <p>TicketType.php</p>
  
  <pre><code>namespace App\Models;
  
  use App\Models\Abstracts\TypeModelAbstract;
  use App\Models\Interfaces\TypeModelInterface;
  use App\Traits\HasSlug;
  
  class TicketType extends TypeModelAbstract implements TypeModelInterface {
  
      use HasSlug;
  
      protected $fillable = [
          'title',
          'slug',
          ...
      ];
  
      ...
  
      public static function boot() {
  
          parent::boot();
  
          static::creating(function ($item) {
              $item-&gt;sluggable();
              \Log::debug('slug is ' . $item-&gt;slug, $item-&gt;attributes);
              // Here $item-&gt;slug is correct, but the slug is not in the attributes array
          });
      }
  </code></pre>
  
  <p>HasSlug.php</p>
  
  <pre><code>namespace App\Traits;
  
  use Illuminate\Support\Facades\Cache;
  
  trait HasSlug {
  
      public function sluggable() {
          if (!$this-&gt;getSlug()) {
              $slug = $this-&gt;buildSlug();
              $this-&gt;setSlug($slug);
          }
          return $this;
      }
  
      public function refreshSlug() {
          $this-&gt;setSlug($this-&gt;buildSlug());
          return $this;
      }
  
      protected function setSlug($slug) {
          // $save_to = static::$sluggable_save_to_attribute ?? 'slug'; -- PHP bug fixed in 7.0.19 and  7.1.5
          $save_to = isset(static::$sluggable_save_to_attribute) ? static::$sluggable_save_to_attribute : 'slug';
          $this-&gt;attributes[$save_to] = $slug;
          // $this-&gt;setAttribute($save_to, $slug);
          return $this;
      }
  
      /**
       * @return \Eloquent
       */
      public function getSlug() {
          // $save_to = static::$sluggable_save_to_attribute ?? 'slug'; -- PHP bug fixed in 7.0.19 and  7.1.5
          $save_to = isset(static::$sluggable_save_to_attribute) ? static::$sluggable_save_to_attribute : 'slug';
          // return $this-&gt;getAttribute($save_to);
          return $this-&gt;$save_to;
      }
  
      /**
       * @return string
       */
      protected static function getRand() {
          $length = 11;
          $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
          $size = strlen($chars);
          $str = '';
          for ($i = 0; $i &lt; $length; $i++) {
              $str .= $chars[rand(0, $size - 1)];
          }
          return $str;
      }
  
      /**
       * @param string $str;
       * @return string;
       */
      protected function mod($str) {
          // if (static::$sluggable_uppercase ?? false ) {  -- PHP bug fixed in 7.0.19 and  7.1.5
          $uppercase = isset(static::$sluggable_uppercase) ? static::$sluggable_uppercase : false;
          if ( $uppercase ) {
              return strtoupper($str);
          } else {
              return $str;
          }
      }
  
      /**
       * @return string
       */
      protected function buildSlug() {
          // $attr = static::$sluggable_build_from_attribute ?? 'title'; -- PHP bug fixed in 7.0.19 and  7.1.5
          $attr = isset(static::$sluggable_build_from_attribute) ? static::$sluggable_build_from_attribute : 'title';
          $string = $attr &amp;&amp; $this-&gt;$attr ? $this-&gt;$attr : static::getRand();
          return $this-&gt;bestSlugFrom($string);
      }
  
      /**
       * @param string $string
       * @return string
       */
      public function bestSlugFrom($string) {
          $original = $slug = $this-&gt;mod(static::sluggify($string));
          $i = 1;
          while (static::findBySlug($slug, true)) {
              $slug = $original . '-' . $i;
              $i++;
          }
          return $slug;
      }
  
      /**
       * Sluggify a string
       * @param string $text
       * @return string
       */
      public static function sluggify($text) {
          $text = str_replace(array('#', 'ω'), array(' sharp', ' omega'), $text); // replace non letter or digits by -
          return str_slug($text);
      }
  
      /**
       * Get a model by the slug
       * @param string $slug
       * @param bool $includeTrashed
       * @return static
       */
      public static function findBySlug($slug, $includeTrashed = false ) {
          // $slugAttr = static::$sluggable_save_to_attribute ?? 'slug'; -- PHP bug fixed in 7.0.19 and  7.1.5
          $slugAttr = isset(static::$sluggable_save_to_attribute) ? static::$sluggable_save_to_attribute : 'slug';
          return Cache::remember( get_called_class() . "_bySlug_{$slug}_{$includeTrashed}", 1, function () use ($slug, $includeTrashed, $slugAttr) {
              $q = static::where($slugAttr ?? 'slug', $slug);
              if ( $includeTrashed &amp;&amp; method_exists(get_called_class(), 'bootSoftDeletingTrait') ) {
                  /* Make sure the model has soft deletes before calling this method */
                  $q-&gt;withTrashed();
              }
              return $q-&gt;first();
          });
      }
  
  }
  </code></pre>