You set the id in the webhook so provided you are getting $user->id then you should be good.
Unless... you have an observer that tries to set the same field.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm using a webhook to process a Stripe transaction. In the webhook I set up the new user account, or upgrade it, as the case may be. I have a table for settings and I pre-populate that with default settings, but one of the fields is created_by_id, which I cannot set. Because the webhook is a side process, there is no Auth::User() or authenticated logged-in user. When I try to save data to the fields, my code creates the new settings record, but leaves the created_by_id field blank. I need that field to associate those settings to their user.
My code in my webhook is:
$newSettings = new Setting;
$newSettings->federalLTCGrate = 15;
$newSettings->stateLTCGrate = 9;
$newSettings->federalITrate = 20;
$newSettings->stateITR = 9.3;
...
$newSettings->created_by_id = $user->id;
Log::info("New Settings: ".$newSettings);
$newSettings->save();
All fields are saved correctly. I can send the data collection to the log , as you can see, and I clearly see the correct user ID for that field in the data array, it just doesn't get saved but everything else is.
I know that is being done in my settings model:
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Traits\FilterByUser;
use Laravelista\Comments\Commentable;
class setting extends Model
{
use FilterByUser, Commentable;
protected $fillable = [
'federalLTCGrate',
'stateLTCGrate',
'federalITrate',
'stateITR',
'commissionREsale',
'closing_costsREsale',
'federalLTGholding_days',
'stateLTGholding_days',
'married_residential_exclusion_limit',
'single_residential_exclusion_limit',
'real_primary_name',
'created_by_id'
];
public function created_by()
{
return $this->belongsTo(User::class, 'created_by_id');
}
}
But how can I override this and force that field to update with the ID number I send it?
Please or to participate in this conversation.