Skip to content

Using the Kanban Module

Overview

The Kanban module is a comprehensive CRM and sales pipeline management system that provides a visual kanban board interface for managing leads, opportunities, and sales processes. It allows teams to track prospects through different stages of the sales funnel using a drag-and-drop interface.

The Kanban module is designed to help sales teams:

  1. Organize sales opportunities in visual kanban boards
  2. Track leads through customizable sales funnels
  3. Manage multiple sales pipelines with different stages
  4. Associate products and values with opportunities
  5. Monitor team performance and sales progress
  6. Handle loss reasons and opportunity analysis

Architecture

The Kanban module is built on several key components:

Core Models

Funnel Model

The Funnel model represents a sales pipeline or process flow. Each funnel defines a specific sales methodology with its own set of stages.

Key Features:

  • Belongs to a specific team
  • Has multiple steps (pipeline stages)
  • Contains multiple opportunities
  • Can be set as default for the team
  • Has customizable sort order

Relationships:

  • belongsTo(Team::class) - Each funnel belongs to a team
  • hasMany(Step::class) - Contains multiple pipeline steps
  • hasMany(Opportunity::class) - Contains multiple opportunities

Fillable Fields:

  • name - The funnel name (e.g., "Sales Pipeline", "Lead Qualification")
  • abbreviation - Short code for the funnel
  • is_default - Boolean flag for default funnel
  • sort - Display order

Step Model

The Step model represents individual stages within a sales funnel (e.g., "Prospecting", "Qualified", "Proposal", "Closed Won").

Key Features:

  • Belongs to a specific funnel
  • Contains multiple opportunities
  • Has customizable sort order for stage progression
  • Observed by StepObserver for automated actions

Relationships:

  • belongsTo(Funnel::class) - Belongs to a parent funnel
  • hasMany(Opportunity::class) - Contains opportunities in this stage

Fillable Fields:

  • funnel_id - Reference to parent funnel
  • name - Step name (e.g., "Qualified Lead", "Proposal Sent")
  • sort - Order within the funnel

Opportunity Model

The Opportunity model is the core entity representing individual sales opportunities that move through the pipeline.

Key Features:

  • Sortable within steps for drag-and-drop functionality
  • Associated with leads, users, and teams
  • Tracks monetary value and timeline
  • Supports loss reasons and descriptions
  • Can have multiple associated products

Relationships:

  • belongsTo(Team::class) - Belongs to a team
  • belongsTo(User::class) - Assigned to a user/salesperson
  • belongsTo(Lead::class) - Associated with a lead
  • belongsTo(Funnel::class) - Part of a specific funnel
  • belongsTo(Step::class) - Currently in a specific step
  • belongsTo(LossReason::class) - Optional loss reason if closed-lost
  • hasMany(OpportunityProduct::class) - Associated products

Fillable Fields:

  • user_id - Assigned salesperson
  • lead_id - Associated lead
  • funnel_id - Parent funnel
  • step_id - Current pipeline stage
  • loss_reason_id - Reason for loss (if applicable)
  • name - Opportunity title
  • value - Monetary value
  • status - Boolean status flag
  • sort - Position within step
  • description - Detailed description
  • loss_reason_description - Additional loss details
  • starts_at - Start date
  • ends_at - Expected close date

Supporting Models

Lead Model

Represents potential customers or prospects that can be converted to opportunities.

Product Model

Represents products or services that can be associated with opportunities.

OpportunityProduct Model

Pivot model linking opportunities with products, allowing multiple products per opportunity.

LossReason Model

Predefined reasons for why opportunities are marked as lost (e.g., "Budget", "Timeline", "Competitor").

Classification Model

Categorization system for organizing leads and opportunities.

Filament Integration

The Kanban module integrates seamlessly with Filament through:

KanbanPlugin

The KanbanPlugin class registers the module with Filament panels:

  • Auto-discovers resources, pages, and widgets
  • Handles module-specific event listeners
  • Integrates with Filament's service container

Resources

The module includes Filament resources for managing:

  • Funnels and their configuration
  • Steps within funnels
  • Opportunities and their details
  • Leads and contact information
  • Products and leadClassifications

Custom Components

The module provides custom Filament components:

  • Kanban board views with drag-and-drop functionality
  • Money input components for opportunity values
  • Custom styling through Blade directives

Blade Directives

The module registers custom Blade directives for easy integration:

@kanbanStyles

Includes the kanban-specific CSS styles:

php
@kanbanStyles

@kanbanScripts

Includes the kanban-specific JavaScript:

php
@kanbanScripts

Usage Examples

Creating a Sales Funnel

php
use Modules\Kanban\Models\Funnel;

// Create a new sales funnel
$funnel = Funnel::create([
    'name' => 'B2B Sales Pipeline',
    'abbreviation' => 'B2B',
    'is_default' => true,
    'sort' => 1,
    'team_id' => auth()->user()->currentTeam->id,
]);

Adding Steps to a Funnel

php
use Modules\Kanban\Models\Step;

// Create pipeline steps
$steps = [
    ['name' => 'Lead', 'sort' => 1],
    ['name' => 'Qualified', 'sort' => 2],
    ['name' => 'Proposal', 'sort' => 3],
    ['name' => 'Negotiation', 'sort' => 4],
    ['name' => 'Closed Won', 'sort' => 5],
    ['name' => 'Closed Lost', 'sort' => 6],
];

foreach ($steps as $stepData) {
    Step::create([
        'funnel_id' => $funnel->id,
        'name' => $stepData['name'],
        'sort' => $stepData['sort'],
    ]);
}

Creating an Opportunity

php
use Modules\Kanban\Models\Opportunity;

// Create a new sales opportunity
$opportunity = Opportunity::create([
    'user_id' => auth()->id(),
    'lead_id' => $lead->id,
    'funnel_id' => $funnel->id,
    'step_id' => $firstStep->id,
    'name' => 'Enterprise Software License',
    'value' => 50000.00,
    'status' => true,
    'description' => 'Potential client interested in our enterprise solution',
    'starts_at' => now(),
    'ends_at' => now()->addDays(30),
]);

Moving Opportunities Through Pipeline

php
// Move opportunity to next step
$nextStep = Step::where('funnel_id', $opportunity->funnel_id)
    ->where('sort', '>', $opportunity->step->sort)
    ->orderBy('sort')
    ->first();

if ($nextStep) {
    $opportunity->update([
        'step_id' => $nextStep->id,
        'sort' => $opportunity->getHighestOrderNumber() + 1,
    ]);
}

Querying Opportunities by Pipeline Stage

php
// Get all opportunities in a specific step
$qualifiedOpportunities = Opportunity::whereHas('step', function ($query) {
    $query->where('name', 'Qualified');
})->with(['lead', 'user', 'products'])->get();

// Get opportunities for a specific funnel
$pipelineOpportunities = Opportunity::where('funnel_id', $funnel->id)
    ->orderBy('step_id')
    ->orderBy('sort')
    ->get();

// Get high-value opportunities
$highValueDeals = Opportunity::where('value', '>', 10000)
    ->where('status', true)
    ->with(['step', 'user'])
    ->get();

Configuration

Module Registration

The Kanban module is automatically registered through:

  1. module.json - Defines the module metadata and providers
  2. KanbanServiceProvider - Registers services and Blade directives
  3. KanbanPlugin - Integrates with Filament panels

Team Integration

The module is designed to work with multi-tenant team structures:

  • Funnels belong to specific teams
  • Opportunities are team-scoped
  • Users can only see their team's data