Skip to main content

Calculator Systems

Profile PS3 provides two specialized calculator systems for erosion control professionals.

Application Rate Calculator

Purpose

Calculate product application rates and coverage for erosion control installations based on:

  • Site dimensions and area
  • Soil conditions and classification
  • Product specifications
  • Application method and requirements

Access

Location: /app/application-calculator

Permissions: All approved users

Model

App\Models\ApplicationCalculator

Key Fields:

id (primary key)
project_id (foreign key to projects, nullable)
user_id (foreign key to users)
name — Calculator instance name
area — Application area (sq ft or acres)
area_unit — Unit of measurement
product_type — ECB, HECP, TRM
selected_product_id — Specific product selection
specifications (JSON) — Input parameters
results (JSON) — Calculation outputs
created_at, updated_at

Calculation Inputs

Site Parameters:

  • Area (square feet or acres)
  • Slope gradient (H:V ratio)
  • Soil type classification
  • Vegetation requirements
  • Climate zone

Product Selection:

  • Product type (ECB/HECP/TRM)
  • Specific product from database
  • Application method
  • Coverage overlap percentage

Calculation Engine

Coverage Calculations:

// Convert acres to square feet
$sqft = $area_unit === 'acres' ? $area * 43560 : $area;

// Calculate product quantity needed
$coverage_per_roll = $product->coverage_sqft;
$overlap_factor = 1 + ($overlap_percentage / 100);
$rolls_needed = ceil(($sqft * $overlap_factor) / $coverage_per_roll);

// Calculate cost
$total_cost = $rolls_needed * $product->price_per_roll;

// Calculate installation time
$install_time = ($sqft / 1000) * $product->install_hours_per_1000sqft;

Soil Factor Adjustments:

  • Clay soils: +10% product requirement
  • Sandy soils: +15% product requirement
  • Rocky terrain: +20% labor time

Results JSON Structure

{
"input": {
"area": 2.5,
"area_unit": "acres",
"slope_gradient": "3:1",
"soil_type": "clay",
"product": "Premium Straw Blanket"
},
"calculations": {
"area_sqft": 108900,
"overlap_factor": 1.1,
"effective_area": 119790,
"rolls_needed": 48,
"linear_feet": 4800
},
"output": {
"product_quantity": 48,
"unit": "rolls",
"coverage": 2.75,
"coverage_unit": "acres",
"material_cost": 14400.00,
"install_hours": 36,
"labor_cost": 2700.00,
"total_cost": 17100.00
},
"recommendations": [
"Use 48 rolls of Premium Straw Blanket",
"Allow 10% overlap for proper coverage",
"Estimated installation: 36 hours",
"Consider additional anchoring on 3:1 slopes",
"Ensure proper seedbed preparation"
]
}

Filament Resource

Location: app/Filament/App/Resources/ApplicationCalculatorResource.php

Form Components:

Forms\Components\Select::make('project_id')
->relationship('project', 'projectNum')
->searchable()
->preload(),

Forms\Components\TextInput::make('name')
->required()
->maxLength(255),

Forms\Components\TextInput::make('area')
->numeric()
->required()
->suffix(fn (Get $get) => $get('area_unit') ?? 'acres'),

Forms\Components\ToggleButtons::make('area_unit')
->options(['acres' => 'Acres', 'sqft' => 'Square Feet'])
->default('acres')
->inline(),

Forms\Components\Select::make('product_type')
->options([
'ecb' => 'Erosion Control Blanket',
'hecp' => 'Hydraulically Applied Product',
'trm' => 'Turf Reinforcement Mat',
])
->required()
->reactive(),

Forms\Components\Select::make('selected_product_id')
->options(function (Get $get) {
$type = $get('product_type');
if (!$type) return [];

return match($type) {
'ecb' => Ecb::pluck('productName', 'Id'),
'hecp' => Hecp::pluck('productName', 'Id'),
'trm' => Trm::pluck('productName', 'Id'),
};
})
->required()
->searchable(),

Forms\Components\Textarea::make('recommendations')
->rows(5)
->disabled(),

PDF Report Generation

Generate professional PDF reports:

use Barryvdh\DomPDF\Facade\Pdf;

$pdf = Pdf::loadView('reports.application-calculator', [
'calculator' => $calculator,
'project' => $calculator->project,
'user' => $calculator->user,
]);

return $pdf->download("application-calc-{$calculator->id}.pdf");

ProGanics BSM Calculator

Purpose

Calculate ProGanics™ Biotic Soil Media (BSM) requirements for soil amendment and restoration projects.

Access

Location: /app/proganics-calculator

Permissions: All approved users

Model

App\Models\ProganicsCalculator

Key Fields:

id (primary key)
project_id (foreign key to projects, nullable)
user_id (foreign key to users)
name — Calculator instance name
specifications (JSON) — BSM input parameters
results (JSON) — BSM calculation outputs
created_at, updated_at

Calculation Inputs

Site Parameters:

  • Treatment area (acres)
  • Application depth (inches)
  • Soil amendment percentage
  • Existing soil characteristics

BSM Parameters:

  • BSM product selection
  • Application rate (tons/acre)
  • Mixing depth
  • Moisture content target

Calculation Engine

Volume Calculations:

// Calculate cubic yards needed
$area_sqft = $acres * 43560;
$depth_ft = $depth_inches / 12;
$cubic_yards = ($area_sqft * $depth_ft) / 27;

// Calculate BSM tonnage
$bsm_density = 1000; // lbs per cubic yard
$total_weight_lbs = $cubic_yards * $bsm_density;
$total_tons = $total_weight_lbs / 2000;

// Calculate cost
$cost_per_ton = $product->price;
$total_cost = $total_tons * $cost_per_ton;

Results JSON Structure

{
"input": {
"area": 5.0,
"area_unit": "acres",
"depth": 4,
"depth_unit": "inches",
"product": "ProGanics BSM Standard"
},
"calculations": {
"area_sqft": 217800,
"depth_ft": 0.333,
"cubic_yards": 2689,
"bsm_tons": 1345
},
"output": {
"bsm_required": 1345,
"unit": "tons",
"material_cost": 94150.00,
"freight_cost": 15000.00,
"install_cost": 35000.00,
"total_cost": 144150.00
},
"recommendations": [
"1,345 tons of ProGanics BSM Standard required",
"Apply at 4-inch depth across 5 acres",
"Mix BSM with existing soil to 6-inch depth",
"Water immediately after application",
"Seed within 24 hours of installation"
]
}

Saving Calculations to Projects

Both calculators support optional project association:

// Create calculation with project
$calculator = ApplicationCalculator::create([
'user_id' => auth()->id(),
'project_id' => $project->Id,
'name' => 'Main Slope Calculation',
'specifications' => $inputData,
'results' => $calculatedResults,
]);

// Project relationship
$project->applicationCalculators; // Collection of calculations

API Endpoints (Internal)

Both calculators expose AJAX endpoints for real-time calculations:

POST /app/api/calculator/application/calculate

{
"area": 2.5,
"area_unit": "acres",
"product_type": "ecb",
"product_id": 15,
"slope_gradient": "3:1",
"soil_type": "clay"
}

Response:

{
"success": true,
"results": {
"rolls_needed": 48,
"cost": 17100.00,
"install_hours": 36
},
"recommendations": [...]
}

Calculator History & Tracking

Users can view all their past calculations:

List View:

  • Filter by project
  • Sort by date
  • Search by name
  • Duplicate calculation feature

Actions:

  • Edit and recalculate
  • Delete calculation
  • Generate PDF report
  • Duplicate to new project
  • Share with team members (future feature)

Testing

Feature Tests (tests/Feature/CalculatorTest.php):

test('application calculator produces accurate results', function () {
$user = User::factory()->create(['approved' => 'approved']);

$response = $this->actingAs($user)
->post('/app/api/calculator/application/calculate', [
'area' => 1,
'area_unit' => 'acres',
'product_type' => 'ecb',
'product_id' => 1,
]);

$response->assertOk()
->assertJsonStructure([
'success',
'results' => ['rolls_needed', 'cost', 'install_hours'],
'recommendations',
]);

expect($response->json('results.rolls_needed'))->toBeGreaterThan(0);
});

Future Enhancements

Planned Features:

  • Mobile calculator app
  • Offline calculation capability
  • Batch project calculations
  • Cost comparison tool
  • Regional pricing adjustments
  • Seasonal factor adjustments
  • Equipment requirement calculator
  • Labor crew sizing calculator