timezone)->format('Y-m-d'); $scheduledAt = Carbon::parse($date, $workspace->timezone) ->setTime(9, 0) ->utc(); $post = $workspace->posts()->create([ 'user_id' => $user->id, 'status' => PostStatus::Draft, 'synced' => true, 'scheduled_at' => $scheduledAt, ]); $socialAccounts = $workspace->socialAccounts()->active()->get(); foreach ($socialAccounts as $account) { $post->postPlatforms()->create([ 'social_account_id' => $account->id, 'platform' => $account->platform->value, 'content' => '', 'content_type' => ContentType::defaultFor($account->platform), 'status' => PostPlatformStatus::Pending, 'enabled' => true, ]); } return $post; } }