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.

873 B
Raw Blame
<?php

declare(strict_types=1);

namespace App\Http\Requests\App\PostTemplate;

use App\Enums\PostTemplate\Visibility;
use App\Models\PostTemplate;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class DuplicateTemplateRequest extends FormRequest
{
    public function authorize(): bool
    {
        $template = $this->route('postTemplate');

        return $template instanceof PostTemplate
            ? $this->user()->can('update', $template)
            : $this->user()->can('create', PostTemplate::class);
    }

    /**
     * @return array<string, mixed>
     */
    public function rules(): array
    {
        return [
            'visibility' => ['required', Rule::enum(Visibility::class)],
        ];
    }

    public function visibility(): Visibility
    {
        return Visibility::from($this->validated('visibility'));
    }
}