Skip to content

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.

848 B
Raw Blame
<?php

declare(strict_types=1);

namespace App\Policies;

use App\Models\IdeaStage;
use App\Models\User;
use Illuminate\Auth\Access\Response;

class IdeaStagePolicy
{
    public function create(User $user): bool
    {
        return $user->currentWorkspace !== null
            && $user->can('createPost', $user->currentWorkspace);
    }

    /**
     * A stage of another workspace is denied as not found, so its existence
     * does not leak across tenants.
     */
    public function update(User $user, IdeaStage $stage): bool|Response
    {
        if ($stage->workspace_id !== $user->current_workspace_id) {
            return Response::denyAsNotFound();
        }

        return $this->create($user);
    }

    public function delete(User $user, IdeaStage $stage): bool|Response
    {
        return $this->update($user, $stage);
    }
}