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
<?php
declare(strict_types=1);
namespace App\Actions\Offer;
use App\Models\Account;
use App\Models\Offer;
use Illuminate\Database\UniqueConstraintViolationException;
class ClaimOffer
{
/**
* Ties an available offer to an account without an active subscription.
* An unknown, unavailable or already redeemed offer is ignored. A request
* racing another one for the same claim finds it already written.
*/
public static function execute(Account $account, string $slug): ?Offer
{
if ($account->hasActiveSubscription()) {
return null;
}
$offer = Offer::findAvailable($slug, $account);
if (blank($offer)) {
return null;
}
try {
$account->offers()->syncWithoutDetaching([$offer->id => ['claimed_at' => now()]]);
} catch (UniqueConstraintViolationException) {
}
return $offer;
}
}