<?php
namespace App\Filament\Pages;
use App\Services\MessageService;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Pages\Actions\Action;
use Filament\Pages\Page;
class Patient extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.patient';
protected static ?string $title = 'Patient profile';
protected static ?string $slug = 'patient/{patientId}/{currentTab?}';
public $patientId;
public $patient;
public $tabs = [];
public $currentTab = 'tab1';
public $subTab = 'subTab1';
protected function getHeaderActions(): array
{
return [
Action::make('Message')
->action(function ($data): void {
dd($data);
$message = [
'from_user_id' => auth()->user()->id,
'to_user_id' => $this->patient->user->id,
'type' => 'patient',
'subject' => $data['subject'],
'message' => $data['message'],
'created_at' => now(),
];
MessageService::createMessages([$message]);
})->icon('heroicon-o-envelope')->label('Message')->modalButton('Send Message')->modalHeading(request()->input('id'))
->form([
TextInput::make('to')->default($this->patient->user->name.' ('.$this->patient->user->email.')')->disabled(),
TextInput::make('subject')->required(),
Textarea::make('message')->required(),
FileUpload::make('files')->label('Attachments')->disk('local')
]),
];
}
public function getTitle(): string
{
return "Test Page";
}