PHP code example of occtherapist / advanced-roster-for-filament

1. Go to this page and download the library: Download occtherapist/advanced-roster-for-filament library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

occtherapist / advanced-roster-for-filament example snippets


use Filament\Panel;
use OccTherapist\AdvancedRosterForFilament\AdvancedRosterForFilamentPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            AdvancedRosterForFilamentPlugin::make(),
        ]);
}

// config/advanced-roster-for-filament.php

return [
    'assignee_model' => \App\Models\User::class,

    'entry_type_enum' => \OccTherapist\AdvancedRosterForFilament\Enums\RosterEntryType::class,

    'validate_overlap' => true,

    'week_starts_at' => 'monday',
    'week_days' => 5,

    'filters' => [
        \OccTherapist\AdvancedRosterForFilament\Support\Filters\AssigneeRosterFilter::class,
        // \App\Roster\Filters\RoleRosterFilter::class,
        // \App\Roster\Filters\LocationRosterFilter::class,
    ],

    'features' => [
        'notes' => true,
        'print' => true,
        'filters' => true,
    ],
];

interface RosterEntryTypeContract
{
    public function isFullDay(): bool;
    public function deletesConflictingEntries(): bool;
}

use Filament\Forms\Components\Select;
use Illuminate\Support\Collection;
use OccTherapist\AdvancedRosterForFilament\Contracts\RosterFilter;
use OccTherapist\AdvancedRosterForFilament\Contracts\RosterScope;

class RoleRosterFilter implements RosterFilter
{
    public function getKey(): string
    {
        return 'role';
    }

    public function getLabel(): string
    {
        return __('Role');
    }

    public function getFormComponent(): Select
    {
        return Select::make($this->getKey())
            ->label($this->getLabel())
            ->options([
                'nurse' => 'Nurse',
                'doctor' => 'Doctor',
                'admin' => 'Admin',
            ])
            ->multiple();
    }

    public function apply(Collection $assignees, mixed $value, ?RosterScope $scope): Collection
    {
        if (! is_array($value) || $value === []) {
            return $assignees;
        }

        return $assignees->filter(
            fn ($assignee) => in_array($assignee->role, $value, true),
        );
    }
}
bash
php artisan vendor:publish --tag=advanced-roster-for-filament-migrations
php artisan migrate
bash
php artisan vendor:publish --tag=advanced-roster-for-filament-config