Laravel mass-assignment insert new record create() alternative?
<p>I have a 'users' table and 'activation_tokens' table. I have a relation in User model as hasOne(ActivationToken::class);</p>

<p>This is all working fine. Now I want to create a token when creating a user. So I call</p>

<pre><code>$user-&gt;ActivationToken()-&gt;create(array('token'=&gt;'RANDOM_STRING")); 
</code></pre>

<p>This is all good, but I am hitting the mass-assignment error. I <em>do not</em> want to set 'token' as fillable. </p>

<p>Instead I try</p>

<pre><code>    $activationToken = new ActivationToken();
    $activationToken-&gt;token = 'RANDOM_STRING";
    $activationToken-&gt;save();
</code></pre>

<p>Which is ok but it does not set the user_id field in query. I guess I could do it manually by setting <code>$activationToken-&gt;user_id = $user-&gt;id;</code> But this feels wrong since the ORM should be handling this automatically as far as documentation seems to advertise. So I think I am doing something wrong?</p>

<p>I couldn't figure out how to do this correctly. Any hints?</p>

<p>Thanks!</p>