<?php

namespace App\Filament\Association\Resources\NoticePostResource\Pages;

use App\Filament\Association\Resources\NoticePostResource;
use Filament\Resources\Pages\CreateRecord;
use Filament\Facades\Filament;

class CreateNoticePost extends CreateRecord
{
    protected static string $resource = NoticePostResource::class;
    
    protected function mutateFormDataBeforeCreate(array $data): array
    {
        $data['association_id'] = Filament::getTenant()->id;
        $data['created_by'] = auth()->id();
        
        return $data;
    }
    
    protected function getRedirectUrl(): string
    {
        return $this->getResource()::getUrl('index');
    }
}
