Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Cine Reserve Laravel Package

przwl/cine-reserve

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:
    composer require przwl/cine-reserve
    php artisan vendor:publish --tag=cine-reserve-config
    
  2. Register Plugin in AdminPanelProvider.php:
    ->plugins([
        CineReserve::make(),
    ])
    
  3. Publish Config and update config/cine-reserve.php with basic settings (e.g., rows, seats_per_row, colors).

First Use Case

Display a Seat Selection UI in a Filament resource/page:

use Przwl\CineReserve\Filament\Widgets\CineReserveWidget;

public static function getWidgets(): array
{
    return [
        CineReserveWidget::make()
            ->movie('Inception')
            ->showPrice(true)
            ->maxSeats(10),
    ];
}

Implementation Patterns

Core Workflow

  1. Seat Selection UI:

    • Use CineReserveWidget in Filament resources/pages.
    • Customize via methods:
      CineReserveWidget::make()
          ->movie('Movie Title')
          ->rows(10)
          ->seatsPerRow(8)
          ->colors(['available' => 'green', 'booked' => 'red'])
          ->showPrice(true)
          ->maxSeats(5)
      
  2. Data Binding:

    • Pass existing bookings via bookedSeats():
      ->bookedSeats(fn () => $this->getBookedSeats()) // Closure or array
      
    • Sync selections with a model:
      ->submitAction(fn (array $selectedSeats) => $this->createBooking($selectedSeats))
      
  3. Dynamic Configuration:

    • Override defaults per instance:
      CineReserveWidget::make()
          ->dynamicConfig(fn () => [
              'rows' => $this->getAvailableRows(),
              'seats_per_row' => $this->getSeatsPerRow(),
          ])
      

Integration Tips

  • Filament Resources: Integrate with create/edit forms for booking workflows:

    use Przwl\CineReserve\Filament\Components\CineReserveComponent;
    
    public function form(Form $form): Form
    {
        return $form
            ->schema([
                CineReserveComponent::make()
                    ->movie($this->movie->title)
                    ->bookedSeats($this->getExistingBookings())
                    ->submitAction(fn (array $seats) => $this->updateBookings($seats)),
            ]);
    }
    
  • API/Backend Logic: Use the submitAction to handle seat selection data:

    ->submitAction(fn (array $selectedSeats) => {
        $this->validateSeats($selectedSeats);
        $this->processPayment($selectedSeats);
        $this->saveToDatabase($selectedSeats);
    })
    
  • Theming: Extend default styles via published assets:

    php artisan vendor:publish --tag=cine-reserve-assets
    

    Override in resources/css/app.css:

    .cine-reserve-seat.available { background: #4CAF50; }
    

Gotchas and Tips

Pitfalls

  1. Seat Indexing:

    • Seats are zero-indexed by row (e.g., ['A1', 'A2', ...]). Validate backend logic matches this format.
    • Fix: Use ->seatFormatter(fn ($row, $seat) => "{$row}{$seat + 1}") for 1-based display.
  2. Dark Mode Conflicts:

    • Custom colors may not render correctly in dark mode if not using Filament’s color palette.
    • Fix: Use Filament’s predefined colors (e.g., 'gray-500') or ensure CSS variables are respected.
  3. Concurrent Bookings:

    • No built-in locking mechanism. Handle race conditions in submitAction:
      ->submitAction(fn (array $seats) => {
          if ($this->areSeatsAvailable($seats)) {
              $this->bookSeats($seats);
          } else {
              throw new \Exception('Seats no longer available.');
          }
      })
      
  4. Performance:

    • Large seat grids (e.g., 20x20) may lag. Optimize with:
      ->rows(10) // Limit rows
      ->lazyLoad(true) // Load seats dynamically (if supported in future updates)
      

Debugging

  • Log Seat Data: Dump selected seats in submitAction:

    ->submitAction(fn (array $seats) => {
        \Log::info('Selected seats:', $seats);
        // ...
    })
    
  • Check Config: Verify config/cine-reserve.php for typos in keys like register_navigation.

Extension Points

  1. Custom Seat Types: Override seat rendering via a custom component:

    CineReserveWidget::make()
        ->seatComponent(CustomSeatComponent::class)
    

    Example: Highlight VIP seats differently.

  2. Validation: Add custom rules to submitAction:

    ->submitAction(fn (array $seats) => {
        if (count($seats) > 2) {
            throw new \Exception('Maximum 2 seats allowed.');
        }
    })
    
  3. Localization: Extend language strings via config/cine-reserve.php:

    'labels' => [
        'seat_selected' => 'Your Seat',
    ],
    
  4. Event Listeners: Listen for seat selection changes (if plugin emits events in future):

    // Hypothetical future usage
    event(new \Przwl\CineReserve\Events\SeatsSelected($seats));
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours