title: Laravel 4 using UUID as primary key
body: <p>I am setting up my first Laravel 4 app and the specs call for the id fields to be varchar(36) and be a UUID.</p>
  
  <p>Using Eloquent, my migrations for a sample table looks like this: </p>
  
  <pre><code>Schema::create('users', function($table)
  {
      $table-&gt;string('id', 36)-&gt;primary;
      $table-&gt;string('first_name', 50);
      $table-&gt;string('last_name', 50);
      $table-&gt;string('email')-&gt;unique();
      $table-&gt;string('password', 60);
      $table-&gt;timestamps();
      $table-&gt;softDeletes();
  });
  </code></pre>
  
  <p>When the users table gets created, the id field is not defined as PK, or unique. It gets defined as varchar(36) NOT NULL.</p>
  
  <p>Why is this happening when I run the migration? </p>
  
  <hr>
  
  <p>My original question was about using UUIDs, but I have sense solved that by adding this to my Users model in case anyone else sees this post:</p>
  
  <pre><code>protected $hidden = array('password');
  
  protected $fillable = array('id', 'first_name', 'last_name', 'email', 'password');
  </code></pre>
  
  <p>Here is my route for adding a user (I am using a function to create the UUID):</p>
  
  <pre><code>Route::post('signup', function()
  {
      $userdata = array(
          'id' =&gt; gen_uuid(),
          'first_name' =&gt; Input::get('first_name'),
          'last_name' =&gt; Input::get('last_name'),
          'email' =&gt; Input::get('email'),
          'password' =&gt; Hash::make(Input::get('password'))    
      );
  
      $user = new User($userdata);
      $user-&gt;save();
  
      return View::make('login/login')-&gt;with('userdata', $userdata);
  }); 
  </code></pre>