Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.
PHP ai-agentsblueskyfacebookinstagramlaravellinkedinmastodonmcpmcp-serveropen-sourcerest-apiself-hostedsocial-mediasocial-media-managementsocial-media-schedulerthreadstiktokvuejsxyoutube
refactor: derive sibling key in content-type rules without regex
Paulo Castellano6949ee4ec327
diff --git a/app/Rules/ContentTypeMatchesPlatform.php b/app/Rules/ContentTypeMatchesPlatform.phpindex 4e6ab8516..56e945c24 100644--- a/app/Rules/ContentTypeMatchesPlatform.php+++ b/app/Rules/ContentTypeMatchesPlatform.php@@ -9,6 +9,7 @@ use App\Models\SocialAccount;use Closure;use Illuminate\Contracts\Validation\DataAwareRule;use Illuminate\Contracts\Validation\ValidationRule;+use Illuminate\Support\Str;/*** Cross-validates platforms[].content_type against platforms[].social_account_id@@ -34,10 +35,10 @@ class ContentTypeMatchesPlatform implements DataAwareRule, ValidationRulepublic function validate(string $attribute, mixed $value, Closure $fail): void{- // attribute is e.g. "platforms.0.content_type" — the sibling- // social_account_id lives at "platforms.0.social_account_id".- $accountKey = preg_replace('/\.content_type$/', '.social_account_id', $attribute);- $accountId = data_get($this->data, $accountKey);+ // attribute is e.g. "platforms.0.content_type" — peel off the leaf+ // and look up the sibling social_account_id under the same parent.+ $parentKey = Str::beforeLast($attribute, '.');+ $accountId = data_get($this->data, $parentKey.'.social_account_id');if (! $accountId) {return;diff --git a/app/Rules/ContentTypeMatchesPostPlatform.php b/app/Rules/ContentTypeMatchesPostPlatform.phpindex b967155a3..b1fe924af 100644--- a/app/Rules/ContentTypeMatchesPostPlatform.php+++ b/app/Rules/ContentTypeMatchesPostPlatform.php@@ -9,6 +9,7 @@ use App\Models\PostPlatform;use Closure;use Illuminate\Contracts\Validation\DataAwareRule;use Illuminate\Contracts\Validation\ValidationRule;+use Illuminate\Support\Str;/*** Cross-validates platforms[].content_type against the platform of the@@ -32,8 +33,8 @@ class ContentTypeMatchesPostPlatform implements DataAwareRule, ValidationRulepublic function validate(string $attribute, mixed $value, Closure $fail): void{- $idKey = preg_replace('/\.content_type$/', '.id', $attribute);- $postPlatformId = data_get($this->data, $idKey);+ $parentKey = Str::beforeLast($attribute, '.');+ $postPlatformId = data_get($this->data, $parentKey.'.id');if (! $postPlatformId) {return;