title: How do I set initial values upon user registration in laravel?
body: <p>I am trying to set a string(16) value as the User ID upon user registration. (This will not change and must be unique. It has 62^16 possibilities so I am not worried about collision at this point.)</p>
  
  <p>I also want to set another random string to act as an activation code. I am having trouble with setting this when the user signs up. I have commented out the lines that are causing trouble (if these are left to run, they are inserted but all the other data is omitted).</p>
  
  <p>Is this where the <em>setters</em> should go?</p>
  
  <p><strong>User.php</strong> (model)</p>
  
  <pre><code>&lt;?php
  
  use Illuminate\Auth\UserInterface;
  use Illuminate\Auth\Reminders\RemindableInterface;
  
  class User extends Eloquent implements UserInterface, RemindableInterface {
  
  
  //    public function __construct()
  //    {
  //        $this-&gt;attributes['mdbid'] = str_random(16);
  //        $this-&gt;attributes['key'] = str_random(11);
  //    }
  
  /**
   * @var string
   */
  protected $primaryKey = 'mdbid';
  /**
   * @var bool
   */
  public $incrementing = false;
  
  // Don't forget to fill this array
  /**
   * @var array
   */
  protected $fillable = array('name', 'dob', 'email', 'username', 'password');
  
  /**
   * The database table used by the model.
   *
   * @var string
   */
  protected $table = 'users';
  
  /**
   * The attributes excluded from the model's JSON form.
   *
   * @var array
   */
  protected $hidden = array('password');
  
  /**
   * Get the unique identifier for the user.
   *
   * @return mixed
   */
  public function getAuthIdentifier()
  {
      return $this-&gt;getKey();
  }
  
  /**
   * Get the password for the user.
   *
   * @return string
   */
  public function getAuthPassword()
  {
      return $this-&gt;password;
  }
  
  /**
   * Get the token value for the "remember me" session.
   *
   * @return string
   */
  public function getRememberToken()
  {
      return $this-&gt;remember_token;
  }
  
  /**
   * Set the token value for the "remember me" session.
   *
   * @param  string  $value
   * @return void
   */
  public function setRememberToken($value)
  {
      $this-&gt;remember_token = $value;
  }
  
  /**
   * Get the column name for the "remember me" token.
   *
   * @return string
   */
  public function getRememberTokenName()
  {
      return 'remember_token';
  }
  
  /**
   * Get the e-mail address where password reminders are sent.
   *
   * @return string
   */
  public function getReminderEmail()
  {
      return $this-&gt;email;
  }
  
  public function setPasswordAttribute($password)
  {
      $this-&gt;attributes['password'] = Hash::make($password);
  }
  </code></pre>
  
  <p>}</p>