### Install BCMath Extension Source: https://github.com/relaticle/flowforge/blob/4.x/UPGRADE.md Provides instructions for installing the BCMath PHP extension on different operating systems to resolve 'Call to undefined function bcadd()' errors. ```bash # Ubuntu/Debian: sudo apt-get install php-bcmath # macOS (Homebrew): # Usually included, check with: php -m | grep bcmath # Windows: # Enable in php.ini: extension=bcmath ``` -------------------------------- ### Complete Column Configuration Example (PHP) Source: https://github.com/relaticle/flowforge/blob/4.x/docs/content/2.essentials/2.customization.md Provides a comprehensive example of configuring multiple columns with various color settings, including semantic colors, Filament constants, and custom hex codes. ```php use Filament\Support\Colors\Color; ->columns([ Column::make('todo') ->color('gray'), // Tailwind color name Column::make('in_progress') ->color(Color::Blue), // Color constant Column::make('review') ->color('primary'), // Semantic color Column::make('done') ->color('#22c55e'), // Custom hex ]) ``` -------------------------------- ### Real-World CardFlex Layout Example (PHP) Source: https://github.com/relaticle/flowforge/blob/4.x/docs/content/2.essentials/2.customization.md Demonstrates a practical application of the CardFlex component within a card schema. This example includes a title, description with character limit, and a CardFlex row containing priority, due date, and assigned user information, all styled as badges with icons. It showcases wrapping and start justification for the flex row. ```php ->cardSchema(fn (Schema $schema) => $schema->components([ TextEntry::make('title') ->weight('bold') ->size('lg'), TextEntry::make('description') ->limit(100) ->color('gray'), CardFlex::make([ TextEntry::make('priority') ->badge() ->icon('heroicon-o-flag'), TextEntry::make('due_date') ->badge() ->date() ->icon('heroicon-o-calendar'), TextEntry::make('assignedTo.name') ->badge() ->icon('heroicon-o-user'), ])->wrap()->justify('start'), ])) ``` -------------------------------- ### Install BCMath PHP Extension (Ubuntu/Debian) Source: https://github.com/relaticle/flowforge/blob/4.x/docs/content/1.getting-started/4.upgrading.md This command installs the BCMath PHP extension on Ubuntu/Debian systems, which is a requirement for Flowforge v3.x and v4.x due to changes in position column type. ```bash # Ubuntu/Debian sudo apt-get install php-bcmath ``` -------------------------------- ### Define Record and Column Actions Source: https://github.com/relaticle/flowforge/blob/4.x/resources/boost/skills/flowforge-development/SKILL.md Sets up actions that can be performed on individual cards (record actions) or on column headers (column actions). Includes examples for editing, archiving, deleting, and adding new tasks. ```php use Filament\Actions\Action; use Filament\Actions\EditAction; use Filament\Actions\DeleteAction; ->recordActions([ EditAction::make() ->url(fn ($record) => route('tasks.edit', $record)), Action::make('archive') ->icon('heroicon-o-archive-box') ->action(fn ($record) => $record->archive()), DeleteAction::make(), ]) ->columnActions([ Action::make('add') ->icon('heroicon-o-plus') ->action(function (array $arguments) { // $arguments['column'] contains column identifier Task::create([ 'status' => $arguments['column'], 'position' => DecimalPosition::forEmptyColumn(), ]); }), ]) ``` -------------------------------- ### Install Flowforge v4.0 Composer Package Source: https://github.com/relaticle/flowforge/blob/4.x/docs/content/1.getting-started/4.upgrading.md This command installs the latest version of the Flowforge package, ensuring compatibility with v4.x features and requirements. ```bash composer require relaticle/flowforge:^4.0 ``` -------------------------------- ### Check PHP bcmath Extension Source: https://github.com/relaticle/flowforge/blob/4.x/UPGRADE.md Verifies if the 'ext-bcmath' PHP extension is installed and enabled on your system. This extension is a new dependency for Flowforge v3.x. ```bash php -m | grep bcmath ``` -------------------------------- ### Register Flowforge Task Board Page in Filament Source: https://github.com/relaticle/flowforge/blob/4.x/docs/content/1.getting-started/3.installation.md Registers the generated Flowforge task board page within your Filament admin panel configuration. This makes the Kanban board accessible through your Filament application. ```php ->pages([ App\Filament\Pages\TaskBoard::class, ]) ``` -------------------------------- ### Livewire Events: Listen to Kanban Events in PHP and JavaScript Source: https://context7.com/relaticle/flowforge/llms.txt This section covers how to listen to Flowforge's Kanban-related Livewire events. It provides examples for both PHP and JavaScript, showing how to register event listeners for actions like card movements and item loading. These listeners allow for custom logic and integrations based on user interactions within the Kanban board. ```php info("Card {$cardId} moved to {$columnId} at position {$position}"); } #[On('kanban-items-loaded')] public function onItemsLoaded(string $columnId, int $loadedCount, int $totalCount, bool $isFullyLoaded): void { // Track loading progress if ($isFullyLoaded) { logger()->info("All {$totalCount} items loaded for column {$columnId}"); } } #[On('kanban-all-items-loaded')] public function onAllItemsLoaded(string $columnId, int $totalCount): void { // Handle "Load All" completion logger()->info("Load All completed for {$columnId}: {$totalCount} items"); } ``` ```javascript // JavaScript Event Listeners document.addEventListener('livewire:init', () => { Livewire.on('kanban-card-moved', ({ cardId, columnId, position }) => { console.log(`Card ${cardId} moved to ${columnId} at position ${position}`); // Update external analytics analytics.track('kanban_card_moved', { cardId, columnId }); }); Livewire.on('kanban-items-loaded', ({ columnId, loadedCount, totalCount, isFullyLoaded }) => { console.log(`Column ${columnId}: ${loadedCount}/${totalCount} loaded`); }); }); ``` -------------------------------- ### Install Flowforge with Composer Source: https://github.com/relaticle/flowforge/blob/4.x/README.md This command installs the Flowforge package using Composer, the dependency manager for PHP. Ensure you have PHP 8.3+ and Laravel 12+ installed. ```bash composer require relaticle/flowforge ``` -------------------------------- ### Create Migration for Position Column Source: https://github.com/relaticle/flowforge/blob/4.x/docs/content/1.getting-started/3.installation.md Generates a new migration file to add a 'position' column to your tasks table. This column is essential for Flowforge's Kanban board functionality. ```bash php artisan make:migration add_position_to_tasks_table ``` -------------------------------- ### DecimalPosition API Changes from Rank Source: https://github.com/relaticle/flowforge/blob/4.x/UPGRADE.md Illustrates the transition from the older Rank-based position handling to the new DecimalPosition methods in version 3.x. It highlights how methods for generating and manipulating positions have changed, returning strings directly. ```php // v2.x Rank::forEmptySequence() // v3.x DecimalPosition::forEmptyColumn() // v2.x Rank::after($rank) // v3.x DecimalPosition::after($position) // v2.x Rank::before($rank) // v3.x DecimalPosition::before($position) // v2.x Rank::betweenRanks($a, $b) // v3.x DecimalPosition::between($a, $b) // Includes jitter // v2.x $rank->get() // N/A in v3.x ``` -------------------------------- ### Registering Flowforge Board Page in Filament Resource Source: https://context7.com/relaticle/flowforge/llms.txt Registers a new page route for the Flowforge Kanban board within a Filament resource. This example shows how to add a 'tasks' route to the `CampaignResource`'s `getPages` method, linking it to the `CampaignTaskBoard` page. ```php Pages\ListCampaigns::route('/'), 'create' => Pages\CreateCampaign::route('/create'), 'edit' => Pages\EditCampaign::route('/{record}/edit'), 'tasks' => Pages\CampaignTaskBoard::route('/{record}/tasks'), ]; } ``` -------------------------------- ### Flowforge Artisan Commands for Position Management Source: https://github.com/relaticle/flowforge/blob/4.x/UPGRADE.md Provides command-line tools for diagnosing, rebalancing, and repairing position data within the Flowforge system. These commands help maintain data integrity and resolve ordering issues. ```bash php artisan flowforge:diagnose-positions php artisan flowforge:rebalance-positions php artisan flowforge:repair-positions ``` -------------------------------- ### Blueprint Macro for Decimal Position Column Source: https://github.com/relaticle/flowforge/blob/4.x/UPGRADE.md Demonstrates the change in the `flowforgePositionColumn()` macro, which now defines a `DECIMAL(20,10)` column for storing positions instead of a `VARCHAR` column. ```php // v2.x created: $table->string('position')->nullable()->collation('utf8mb4_bin'); // v3.x creates: $table->decimal('position', 20, 10)->nullable(); ``` -------------------------------- ### Manage Card Loading and Pagination Programmatically (PHP) Source: https://context7.com/relaticle/flowforge/llms.txt Control card loading and pagination within columns using PHP methods. This includes loading specific numbers of items, loading all items for reordering, checking if a column is fully loaded, getting the position for new cards, and programmatically moving cards between columns. ```php loadMoreItems('todo', 20); // Load all cards to enable reordering $this->loadAllItems('in_progress'); // Check if all cards are loaded (drag-drop only enabled when true) $isReady = $this->isColumnFullyLoaded('review'); // Get position for new card at bottom of column $position = $this->getBoardPositionInColumn('done'); // Move card programmatically $this->moveCard( cardId: '123', targetColumnId: 'in_progress', afterCardId: '456', // Card above (optional) beforeCardId: '789' // Card below (optional) ); ``` -------------------------------- ### Update Flowforge Position Service Usage (v2.x to v3.x/v4.x) Source: https://github.com/relaticle/flowforge/blob/4.x/docs/content/1.getting-started/4.upgrading.md This code demonstrates the change in how the position service is used in Flowforge. The `Rank` service from v2.x has been replaced by `DecimalPosition` in v3.x and v4.x, requiring updates to factory code or custom implementations. ```php // Before (v2.x) use Relaticle\Flowforge\Services\Rank; $position = Rank::forEmptySequence()->get(); $position = Rank::after($lastRank)->get(); // After (v3.x/v4.x) use Relaticle\Flowforge\Services\DecimalPosition; $position = DecimalPosition::forEmptyColumn(); $position = DecimalPosition::after($lastPosition); ``` -------------------------------- ### DecimalPosition Service: Calculate and Manage Item Positions Source: https://context7.com/relaticle/flowforge/llms.txt The DecimalPosition service offers methods to calculate and manage item positions in a programmatic way. It supports operations like getting initial positions, positions after/before existing items, between two bounds, and exact midpoints. It also includes utilities for checking rebalancing needs, generating sequences, and comparing positions. This service is crucial for maintaining order in dynamic lists or boards. ```php dropColumn('position'); }); Schema::table('tasks', function (Blueprint $table) { $table->flowforgePositionColumn(); }); } ``` -------------------------------- ### Manage Drag-Drop with Pagination in PHP Source: https://github.com/relaticle/flowforge/blob/4.x/docs/content/2.essentials/5.troubleshooting.md Demonstrates how to programmatically load all items in a column to enable drag-and-drop functionality when pagination is active, preventing data corruption. ```php // Check if column is fully loaded $this->isColumnFullyLoaded('todo'); // Returns false with pagination // Load all cards programmatically $this->loadAllItems('todo'); // Now drag-drop is enabled $this->isColumnFullyLoaded('todo'); // Returns true ``` -------------------------------- ### Optimize Board Performance in PHP Source: https://github.com/relaticle/flowforge/blob/4.x/docs/content/2.essentials/5.troubleshooting.md Improves board loading speed by optimizing database queries, including eager loading relationships and selecting only necessary fields. ```php // Optimized query example ->query( Task::query() ->with(['assignee', 'priority']) // Eager load relationships ->select(['id', 'title', 'status', 'position']) // Select only needed fields ) ``` -------------------------------- ### Repair Position Collisions and Order Source: https://github.com/relaticle/flowforge/blob/4.x/UPGRADE.md Guides users on how to resolve unique constraint violations or order preservation issues after migration by using the `flowforge:repair-positions` artisan command with the 'regenerate' strategy. ```bash php artisan flowforge:repair-positions # Select "regenerate" strategy ``` -------------------------------- ### Repair Flowforge Positions Command Source: https://github.com/relaticle/flowforge/blob/4.x/docs/content/1.getting-started/3.installation.md An optional command to fix corrupted or missing position data in your Flowforge Kanban board. This is useful for maintaining data integrity. ```bash php artisan flowforge:repair-positions ``` -------------------------------- ### Configure Flowforge Board with Essential Settings (PHP) Source: https://github.com/relaticle/flowforge/blob/4.x/docs/content/2.essentials/4.api-reference.md Sets up the core configuration for a Flowforge board, including the data source, column identifier, position identifier, and column definitions. This is a fundamental step for initializing a board. ```php public function board(Board $board): Board { return $board ->query(Task::query()) // Required: Data source ->columnIdentifier('status') // Required: Column field ->positionIdentifier('position') // Required: Position field ->columns([ Column::make('todo')->label('To Do')->color('gray'), Column::make('done')->label('Done')->color('green'), ]); } ``` -------------------------------- ### Configure Flowforge Kanban Board Source: https://context7.com/relaticle/flowforge/llms.txt Sets up the configuration for a Flowforge Kanban board, defining the data source, column and position identifiers, and the specific columns with their labels and icons. ```php query(Task::query()) // Required: Data source ->columnIdentifier('status') // Required: Column field ->positionIdentifier('position') // Required: Position field ->columns([ Column::make('todo') ->label('To Do') ->color('gray') ->icon('heroicon-o-queue-list'), Column::make('in_progress') ->label('In Progress') ->color('blue') ->icon('heroicon-o-play'), Column::make('review') ->label('Review') ->color('amber') ->icon('heroicon-o-eye'), Column::make('completed') ->label('Completed') ->color('green') ->icon('heroicon-o-check'), ]); } } ``` -------------------------------- ### Add Flowforge Position Column to Database Schema Source: https://github.com/relaticle/flowforge/blob/4.x/docs/content/1.getting-started/3.installation.md Applies the 'position' column to your database table using a migration. The `flowforgePositionColumn` method automatically handles database-specific collations. ```php Schema::table('tasks', function (Blueprint $table) { $table->flowforgePositionColumn('position'); // Handles database-specific collations automatically }); ``` -------------------------------- ### Handle Manual Card Movement in Livewire Source: https://github.com/relaticle/flowforge/blob/4.x/resources/boost/skills/flowforge-development/SKILL.md Demonstrates how to implement manual card movement within a Livewire component. It calls the parent method for position calculation and saving, and allows for custom logic after the move. ```php // In your Livewire component public function moveCard( int|string $recordId, string $toColumn, ?string $afterRecordId = null, ?string $beforeRecordId = null ): void { // Parent handles position calculation and saving parent::moveCard($recordId, $toColumn, $afterRecordId, $beforeRecordId); // Add custom logic after move $this->dispatch('card-moved'); } ``` -------------------------------- ### Update Flowforge Composer Dependency Source: https://github.com/relaticle/flowforge/blob/4.x/UPGRADE.md Updates the Flowforge package to version 3.0 or higher using Composer. This command fetches the latest version and its dependencies. ```bash composer require relaticle/flowforge:^3.0 ``` -------------------------------- ### Configure Standalone Livewire Kanban Board Source: https://github.com/relaticle/flowforge/blob/4.x/README.md This PHP code demonstrates how to set up a Kanban board using Flowforge within a standalone Livewire component. It requires the `InteractsWithBoard` trait and defines the board's query, column identifiers, and column configurations. ```php use Relaticle\Flowforge\Concerns\InteractsWithBoard; class TaskBoard extends Component implements HasBoard { use InteractsWithBoard; public function board(Board $board): Board { return $board ->query(Task::query()) ->columnIdentifier('status') ->positionIdentifier('position') ->columns([ Column::make('todo')->label('To Do')->color('gray'), Column::make('in_progress')->label('In Progress')->color('blue'), Column::make('completed')->label('Completed')->color('green'), ]); } } ``` -------------------------------- ### Configure Column Appearance with PHP Source: https://github.com/relaticle/flowforge/blob/4.x/docs/content/2.essentials/2.customization.md Demonstrates how to configure a column's label, color, and icon using the Filament PHP framework. It supports various color formats and icon libraries. ```php use Filament\Support\Colors\Color; Column::make('todo') ->label('To Do') ->color('gray') // Supports multiple color formats ->icon('heroicon-o-queue-list') ``` -------------------------------- ### Configure Flowforge Board (PHP) Source: https://github.com/relaticle/flowforge/blob/4.x/resources/boost/skills/flowforge-development/SKILL.md Configures a Flowforge Kanban board by defining the Eloquent model query, column identifiers, position identifiers, record title attribute, and the board's columns. This is typically done within a `BoardPage` class. ```php use Relaticle\Flowforge\BoardPage; use Relaticle\Flowforge\Board; use Relaticle\Flowforge\Column; class TaskBoard extends BoardPage { protected static ?string $navigationIcon = 'heroicon-o-view-columns'; public function board(Board $board): Board { return $board ->query(Task::query()) ->columnIdentifier('status') ->positionIdentifier('position') ->recordTitleAttribute('title') ->columns([ Column::make('todo', 'To Do') ->icon('heroicon-o-clipboard'), Column::make('in_progress', 'In Progress') ->icon('heroicon-o-play'), Column::make('done', 'Done') ->icon('heroicon-o-check'), ]); } } ``` -------------------------------- ### Flowforge Diagnostic Artisan Commands Source: https://github.com/relaticle/flowforge/blob/4.x/docs/content/1.getting-started/4.upgrading.md These Artisan commands are new in Flowforge v3.x and are used for diagnosing and managing position data within the application. `diagnose-positions` checks for issues, while `rebalance-positions` redistributes them. ```bash php artisan flowforge:diagnose-positions # Check for issues php artisan flowforge:rebalance-positions # Redistribute positions ``` -------------------------------- ### Generate Flowforge Boards with Artisan Source: https://github.com/relaticle/flowforge/blob/4.x/resources/boost/skills/flowforge-development/SKILL.md Provides artisan commands to generate new Flowforge boards. The `make-board` command creates a new board, with an option to generate it for a resource page. ```bash php artisan flowforge:make-board TaskBoard php artisan flowforge:make-board TaskBoard --resource # For resource page ``` -------------------------------- ### Diagnose Flowforge Positions Artisan Command Source: https://github.com/relaticle/flowforge/blob/4.x/UPGRADE.md Runs the Flowforge diagnose command to check for any inconsistencies or issues with item positions after the migration. Requires specifying the model, column, and position fields. ```bash php artisan flowforge:diagnose-positions \ --model=App\\Models\\YourModel \ --column=status \ --position=position ``` -------------------------------- ### Configure Dynamic Columns from Database (PHP) Source: https://github.com/relaticle/flowforge/blob/4.x/resources/boost/skills/flowforge-development/SKILL.md This PHP snippet shows how to dynamically configure board columns based on data from the database, specifically using a 'Status' model. It maps database statuses to Filament `Column` objects, allowing for customizable board views. This enhances flexibility in representing task states. ```php public function board(Board $board): Board { $statuses = Status::ordered()->get(); return $board ->query(Task::query()) ->columnIdentifier('status_id') ->positionIdentifier('position') ->columns( $statuses->map(fn ($status) => Column::make($status->id, $status->name) ->icon($status->icon) ->color($status->color) )->toArray() ); } ``` -------------------------------- ### Enable Actions with Traits and Models in PHP Source: https://github.com/relaticle/flowforge/blob/4.x/docs/content/2.essentials/5.troubleshooting.md Configures card and column actions by ensuring the component uses required traits and that actions are properly defined with their associated models. ```php class TaskBoard extends BoardPage { use InteractsWithActions; // Required use InteractsWithForms; // Required public function board(Board $board): Board { return $board ->cardActions([ EditAction::make()->model(Task::class), // Model required ]); } } ``` -------------------------------- ### Include Flowforge CSS Assets in Filament Theme Source: https://github.com/relaticle/flowforge/blob/4.x/docs/content/1.getting-started/3.installation.md Adds Flowforge's CSS views to your custom Filament theme. This requires a pre-existing custom Filament theme. Ensure the path correctly points to the vendor directory. ```css @source "../../../../vendor/relaticle/flowforge/resources/views/**/*.blade.php"; ``` -------------------------------- ### Integrate Kanban Board with Filament Resource Source: https://github.com/relaticle/flowforge/blob/4.x/docs/content/2.essentials/1.integration-patterns.md This snippet shows how to create a Kanban board view for a Filament resource, specifically for campaign tasks. It defines the board's columns and queries tasks related to the current campaign and user's team. This is registered as a new page within the resource. ```php query( // Get tasks for this specific campaign and current user's team $this->getRecord() ->tasks() ->whereHas('team', fn($q) => $q->where('id', auth()->user()->current_team_id)) ->getQuery() ) ->columnIdentifier('status') ->positionIdentifier('position') ->columns([ Column::make('backlog')->label('Backlog')->color('gray'), Column::make('in_progress')->label('In Progress')->color('blue'), Column::make('review')->label('Review')->color('amber'), Column::make('completed')->label('Completed')->color('green'), ]); } } // Register in your CampaignResource public static function getPages(): array { return [ 'index' => Pages\ListCampaigns::route('/'), 'create' => Pages\CreateCampaign::route('/create'), 'edit' => Pages\EditCampaign::route('/{record}/edit'), 'tasks' => Pages\CampaignTaskBoard::route('/{record}/tasks'), // Add this line ]; } ``` -------------------------------- ### Control Flowforge Pagination (PHP) Source: https://github.com/relaticle/flowforge/blob/4.x/docs/content/2.essentials/4.api-reference.md Offers methods to manage card pagination within columns, including loading more items, loading all items for reordering, checking if a column is fully loaded, and getting the position for a new card. ```php // Load more cards for pagination $this->loadMoreItems(string $columnId, ?int $count = null) // Load all cards to enable reordering $this->loadAllItems(string $columnId) // Check if all cards are loaded $this->isColumnFullyLoaded(string $columnId): bool // Get position for new card in column $this->getBoardPositionInColumn(string $columnId): string ``` -------------------------------- ### Debug Empty Board Display in PHP Source: https://github.com/relaticle/flowforge/blob/4.x/docs/content/2.essentials/5.troubleshooting.md Helps diagnose why a board might be rendering but showing no cards. It involves temporarily dumping query results and verifying status values match column identifiers. ```php // Add to board method temporarily dd($this->getEloquentQuery()->get()); ``` ```php // Check for global scopes, soft deletes, etc. ->query(Task::withoutGlobalScopes()->get()) ``` -------------------------------- ### Flowforge Card Component HTML Structure Source: https://github.com/relaticle/flowforge/blob/4.x/resources/docs/css-guidelines.md An example of the HTML structure for a Flowforge card component, showcasing the use of BEM classes for the main block, its elements (like title, body, description), and modifiers (like priority). ```html
Description text