jeffersongoncalves/laravel-how-it-works

A Laravel package for managing 'how it works' steps with translatable titles and descriptions

Maintainers

Package info

github.com/jeffersongoncalves/laravel-how-it-works

pkg:composer/jeffersongoncalves/laravel-how-it-works

Transparency log

Fund package maintenance!

jeffersongoncalves

Statistics

Installs: 21

Dependents: 1

Suggesters: 0

Stars: 1

Open Issues: 0

1.0.0 2026-08-29 22:59 UTC

This package is auto-updated.

Last update: 2026-08-29 22:59:45 UTC


README

Laravel How It Works

Laravel How It Works

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads License

A Laravel package for managing an ordered list of "how it works" steps — icon + translatable title/description — for landing-page style sections, powered by spatie/laravel-translatable.

Features

  • Steps — Icon, title, description, order, and active flag for each step
  • Translatable Content — Titles and descriptions are translatable via spatie/laravel-translatable, with automatic fallback to the app's fallback locale
  • Ordering & Activationordered() and active() query scopes
  • Configurable Table Name — Override the how_it_works_steps table name via config
  • Configurable Locales — Mirrors app.available_locales (or the app locale) to describe supported translation locales

Requirements

  • PHP 8.2+
  • Laravel 12.x or 13.x

Installation

You can install the package via composer:

composer require jeffersongoncalves/laravel-how-it-works

Publish and run the migrations:

php artisan vendor:publish --tag="how-it-works-migrations"
php artisan migrate

Publish the config file (optional):

php artisan vendor:publish --tag="how-it-works-config"

Configuration

The config file (config/how-it-works.php) covers:

Table Names

'table_names' => [
    'steps' => 'how_it_works_steps',
],

Locales

'locales' => config('app.available_locales')
    ? array_keys(config('app.available_locales'))
    : [config('app.locale', 'en')],

Reads from app.available_locales (an array keyed by locale code, e.g. ['en' => 'English', 'pt_BR' => 'Português']) when present, otherwise falls back to the app's default locale. The package also configures spatie/laravel-translatable's fallback behavior on boot, so a missing translation for the current locale falls back to app.fallback_locale (or any available locale if that is also missing).

Usage

use JeffersonGoncalves\HowItWorks\Models\Step;

$step = Step::create([
    'icon' => 'heroicon-o-user-plus',
    'title' => ['en' => 'Create an account', 'pt_BR' => 'Crie uma conta'],
    'description' => ['en' => 'Sign up in seconds.', 'pt_BR' => 'Cadastre-se em segundos.'],
    'order' => 1,
    'is_active' => true,
]);

$step->title; // resolved for the current app locale, with fallback

Scopes

Step::active()->ordered()->get();

Translations

Because the model uses Spatie\Translatable\HasTranslations, the full spatie/laravel-translatable API is available:

$step->getTranslation('title', 'pt_BR');
$step->setTranslation('title', 'pt_BR', 'Crie uma conta');
$step->getTranslations('title'); // ['en' => '...', 'pt_BR' => '...']
$step->translate('title', 'pt_BR');

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.