> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devdeia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> Install the package, add a recurrence column, and wire it into a model.

<Steps>
  <Step title="Install via Composer">
    ```bash theme={null}
    composer require andreia/filament-recurrence
    ```
  </Step>

  <Step title="Add a recurrence column to your table">
    Recurrence is stored as JSON on **your** model's table. Add a nullable `json` column — name it however you like; the rest of these docs assume `recurrence`:

    ```bash theme={null}
    php artisan make:migration add_recurrence_to_your_table
    ```

    ```php theme={null}
    use Illuminate\Database\Migrations\Migration;
    use Illuminate\Database\Schema\Blueprint;
    use Illuminate\Support\Facades\Schema;

    return new class extends Migration
    {
        public function up(): void
        {
            Schema::table('your_table', function (Blueprint $table) {
                $table->json('recurrence')->nullable()->after('your_column');
            });
        }

        public function down(): void
        {
            Schema::table('your_table', function (Blueprint $table) {
                $table->dropColumn('recurrence');
            });
        }
    };
    ```

    ```bash theme={null}
    php artisan migrate
    ```
  </Step>

  <Step title="Publish the config (optional)">
    ```bash theme={null}
    php artisan vendor:publish --tag="filament-recurrence-config"
    ```

    See [Configuration](/filament/recurrence/configuration) for every option.
  </Step>

  <Step title="Add the vendor directory to your theme">
    ```css theme={null}
    @source '../../../../vendor/andreia/filament-recurrence';
    ```

    Then rebuild:

    ```bash theme={null}
    npm run build
    ```
  </Step>

  <Step title="Wire it into your model">
    Add the cast (and optionally the trait) to the model that owns the recurrence column:

    ```php theme={null}
    use Andreia\FilamentRecurrence\Casts\RecurrenceCast;
    use Andreia\FilamentRecurrence\Concerns\HasRecurrence;

    class Event extends Model
    {
        use HasRecurrence;

        protected $casts = [
            'recurrence' => RecurrenceCast::class,
        ];
    }
    ```

    The trait adds:

    ```php theme={null}
    $event->getRecurrenceData();          // RecurrenceData object
    $event->getNextOccurrence();          // Next occurrence as Carbon
    $event->getUpcomingOccurrences(10);   // Next 10 occurrences
    $event->occursOn(Carbon::parse('2024-12-25'));

    // Query scopes
    Event::occursOn(Carbon::today())->get();
    Event::occursBetween(Carbon::now(), Carbon::now()->addMonth())->get();
    ```
  </Step>
</Steps>

Next: add the [form field, table column, and infolist entry](/filament/recurrence/usage) to your resource.
