fuelviews/laravel-sabhero-estimator
Installation:
composer require fuelviews/laravel-sabhero-estimator
php artisan sabhero-estimator:install
resources/views/vendor/sabhero-estimator and config/sabhero-estimator.php.First Use Case:
php artisan migrate
/estimator) is registered in the package.Quick Start:
EstimatorForm Livewire component in your Blade view:
@livewire('sabhero-estimator::estimator-form')
app/Providers/Filament/AdminPanelProvider.php:
public function panel(Panel $panel): Panel
{
return $panel
->resources([
\SabheroEstimator\Filament\Resources\EstimateResource::class,
]);
}
Project Creation:
Estimate model to create new estimates:
use SabheroEstimator\Models\Estimate;
$estimate = Estimate::create([
'project_name' => 'Living Room Refresh',
'project_type' => 'interior',
'client_name' => 'John Doe',
'client_email' => 'john@example.com',
]);
estimateRooms() relationship:
$estimate->estimateRooms()->attach($roomId, ['area_sqft' => 1200, 'walls' => 4]);
Livewire Integration:
EstimatorForm component to customize logic:
namespace App\Livewire;
use SabheroEstimator\Livewire\EstimatorForm as BaseEstimatorForm;
class CustomEstimatorForm extends BaseEstimatorForm
{
public function calculateEstimate()
{
// Override or extend calculation logic
$this->estimate->material_cost = $this->customCalculation();
}
}
estimateUpdated event to trigger actions post-calculation:
protected function estimateUpdated()
{
$this->emit('estimateCalculated', $this->estimate);
}
Filament Resource Customization:
public static function table(Table $table): Table
{
return $table
->columns([
Columns\TextColumn::make('project_name')
->searchable(),
Columns\TextColumn::make('status')
->badge(),
Columns\TextColumn::make('total_cost')
->money('USD'),
]);
}
API Endpoints:
EstimateController to expose endpoints:
Route::apiResource('estimates', \SabheroEstimator\Http\Controllers\EstimateController::class);
return Estimate::with(['estimateRooms', 'materials'])->get();
EstimateRequest form request to add custom rules:
namespace App\Http\Requests;
use SabheroEstimator\Http\Requests\EstimateRequest as BaseEstimateRequest;
class CustomEstimateRequest extends BaseEstimateRequest
{
public function rules()
{
return array_merge(parent::rules(), [
'custom_field' => 'required|string',
]);
}
}
resources/lang/vendor/sabhero-estimator.php artisan vendor:publish --tag=sabhero-estimator-assets
Migration Conflicts:
estimates or estimate_rooms tables, drop them before running sabhero-estimator:install to avoid conflicts.php artisan migrate:fresh if needed.Livewire Component Naming:
EstimatorForm), as it may override the package’s functionality.CustomEstimatorForm).Filament Resource Registration:
app/Providers/Filament/AdminPanelProvider.php. Missing this will break the /admin/estimates route.php artisan filament:install if Filament resources aren’t loading.Calculation Logic:
calculateEstimate() method in your Livewire component if you need custom logic.Asset Loading:
php artisan vendor:publish --tag=sabhero-estimator-assets --force
/vendor/sabhero-estimator/....Log Estimates:
config/sabhero-estimator.php:
'logging' => [
'enabled' => true,
'channel' => 'single',
],
storage/logs/laravel.log.Livewire Events:
wire:ignore or wire:model.debounce to optimize form performance:
<input wire:model.debounce.500ms="area_sqft">
Database Seeding:
php artisan db:seed --class=SabheroEstimatorDatabaseSeeder
Custom Fields:
estimate_rooms table via a migration:
Schema::table('estimate_rooms', function (Blueprint $table) {
$table->string('custom_field')->nullable();
});
Material Pricing:
Material model to add custom pricing logic:
namespace App\Models;
use SabheroEstimator\Models\Material;
class CustomMaterial extends Material
{
public function getPricePerUnit()
{
return $this->price_per_unit * 1.1; // Add 10% markup
}
}
Webhooks:
estimate.created or estimate.updated events to trigger external actions (e.g., email notifications):
use SabheroEstimator\Events\EstimateCreated;
Event::listen(EstimateCreated::class, function ($estimate) {
// Send email or update CRM
});
PDF Generation:
EstimatePdf class to generate custom PDFs:
use SabheroEstimator\Services\EstimatePdf;
$pdf = new EstimatePdf($estimate);
return $pdf->download('estimate.pdf');
How can I help you explore Laravel packages today?