title: Laravel: Can't save user object to database
body: <p>I'm following <a href="http://youtu.be/KDkbYDbbt0o?t=14m6s" rel="nofollow">this Laravel login/register tutorial on YouTube</a> and I ran into a problem.</p>
  
  <p>It seems I cannot insert the data from the <code>$user</code> object into my database.
  Everything I have so far works perfectly fine until I reach the <code>$user-&gt;save()</code> method.</p>
  
  <p>The following is my <code>AccountController.php</code>. You'll notice that I'm using <code>print_r</code> to try and debug the process. The first <code>print_r</code> gets printed to my page, but the second never does: Laravel just stops and outputs a cryptic <code>Whoops, looks like something went wrong.</code> warning.</p>
  
  <pre><code>class AccountController extends BaseController {
  
      public function getCreate()
      {
          return View::make('account.create');
      }
  
      public function postCreate()
      {
          $validator = Validator::make(Input::all(), array(
                      'email' =&gt; 'required|max:64|min:3|email|unique:users',
                      'name' =&gt; 'required|max:64|min:3',
                      'password' =&gt; 'required|max:64|min:6'
          ));
  
          if ($validator-&gt;fails())
          {
              // Return to form page with proper error messages
              return Redirect::route('account-create')
                              -&gt;withErrors($validator)
                              -&gt;withInput();
          }
          else
          {
              // Create an acount
              $email = Input::get('email');
              $name = Input::get('name');
              $password = Input::get('password');
  
              // Activation code
              $code = str_random(64);
              $user = User::create(array(
                          'active' =&gt; 0,
                          'email' =&gt; $email,
                          'username' =&gt; $name,
                          'password' =&gt; Hash::make($password),
                          'code' =&gt; $code
              ));
  
              if ($user)
              {
                  // Send the activation link
                  Mail::send('emails.auth.activate', array(
                      'link' =&gt; URL::route('account-activate', $code),
                      'name' =&gt; $name
                          ), function($message) use($user) {
                      $message
                              -&gt;to($user-&gt;email, $user-&gt;username)
                              -&gt;subject('Jasl | Activate your new account');
                  });
  
                  return Redirect::route('home')
                                  -&gt;with('success', 'One more step! You\'ll get an email from us soon. Please follow the activation link to activate your account.');
              }
          }
      }
  
      public function getActivate($code)
      {
          // Find user whose code corresponds to the one we've previously sent through email
          $user = User::where('code', '=', $code)-&gt;where('active', '=', 0);
  
          if ($user-&gt;count())
          {
              $user = $user-&gt;first();
  
              $user-&gt;active = 1;
              $user-&gt;code = '';
  
              echo '&lt;pre&gt;', print_r($user), '&lt;pre&gt;';
              if ($user-&gt;save())
              {
                  echo '-----------------------';
                  echo '&lt;pre&gt;', print_r($user), '&lt;pre&gt;';
              }
          }
      }
  }
  </code></pre>
  
  <p>I've googled a bit and found out that I should create a <code>$fillable</code> array in my <code>User</code> class, so I did it:</p>
  
  <pre><code>use Illuminate\Auth\UserTrait;
  use Illuminate\Auth\UserInterface;
  use Illuminate\Auth\Reminders\RemindableTrait;
  use Illuminate\Auth\Reminders\RemindableInterface;
  
  class User extends Eloquent implements UserInterface, RemindableInterface {
  
      protected $fillable = array('active', 'name', 'email', 'password', 'password_temp', 'code', 'salt', 'created_at', 'updated_at', 'pref_weight', 'pref_units', 'pref_time', 'pref_ener');
  
      use UserTrait,
          RemindableTrait;
  
      /**
       * 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', 'remember_token');
  
  }
  </code></pre>
  
  <p>Those are actually all the elements that my users table has. </p>
  
  <p>This did not solve the problem.</p>
  
  <p>What am I missing? Why isn't <code>$user-&gt;save()</code> working properly?</p>