is_default === true; } /** * User */ public function user(): BelongsTo { return $this->belongsTo(User::class, 'user_id'); } /** * Bootstrap the model and its traits. */ protected static function boot() { parent::boot(); static::creating(function ($address) { if ($address->is_default) { $address->user->addresses()->where('type', $address->type)->update([ 'is_default' => false, ]); } }); } }