labapawel/calendar 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

labapawel/calendar

最新稳定版本:v1.0.0

Composer 安装命令:

composer require labapawel/calendar

包简介

Filament Calendar Component

README 文档

README

A custom calendar component for FilamentPHP, supporting single date and date range selection.

image.png

Installation

You can install the package via composer. Since this is a local package under development, add it to your composer.json repositories:

"repositories": [
    {
        "type": "path",
        "url": "../path/to/calendar"
    }
]

Then require it:

composer require labapawel/calendar:@dev

Configuration

Optionally, you can publish the views using:

php artisan vendor:publish --tag="calendar-views"

Configuration & Usage

Basic Usage

In your Filament Resource or Form:

use LabaPawel\Calendar\Forms\Components\Calendar;

Calendar::make('appointment_date')
    ->label('Appointment Date')

Date Range Selection

To enable picking a start and end date (which enables the "range" mode internally):

Calendar::make('booking_period')
    ->range()

Double View (Two Months)

For a better user experience when selecting ranges, you can show two consecutive months side-by-side. This layout automatically stacks on mobile devices.

Calendar::make('booking_period')
    ->range()
    ->double() // Enables 2-month view
    ->columnSpanFull() // Recommended for double view

Mapping Attributes (Direct Model Saving)

If you ignore the standard JSON storage and want to save directly to start_date and end_date columns on your model, use startAttribute() and endAttribute().

Note: This works automatically for both creating and editing records. You do not need to add hidden fields or model mutators.

Calendar::make('calendar_fields') // Name can be anything unique
    ->range()
    ->double()
    ->startAttribute('start_date') // Column for start date
    ->endAttribute('end_date')     // Column for end date
    ->columnSpanFull()

Database Requirements: The columns (start_date, end_date) must be nullable or have default values if they are optional. The component saves dates in YYYY-MM-DD format.

Localization

The package supports English and Polish. You can publish translations if needed (currently loaded automatically).

To customize translations, you can create files in resources/lang/vendor/calendar/.

Styling

The component uses an external CSS file for styling. If you don't see the styles applied (e.g., date selection color), ensure your assets are published or optimized.

php artisan filament:assets
php artisan optimize:clear

You can customize the appearance by overriding the CSS variables in your global CSS or by modifying the published resources/css/calendar.css file.

Available variables:

  • --c-primary: Main color (defaults to blue).
  • --c-selected-bg: Background color for selected dates.
  • --c-bg, --c-text, --c-border: Theme colors (light/dark mode supported).

Troubleshooting

  • Missing styles? Run php artisan optimize:clear.
  • Wrong date format? Dates are stored as Y-m-d by default to ensure consistency with your database.
  • Missing text? The component uses the browser's Intl.DateTimeFormat for day and month names, defaulting to Polish (pl-PL). Ensure your browser supports this API (all modern ones do).

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: Blade

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-03