### Install Laravel Benefit via Composer Source: https://github.com/jeffersongoncalves/laravel-benefit/blob/main/README.md Install the package via Composer. ```bash composer require jeffersongoncalves/laravel-benefit ``` -------------------------------- ### Publish and Run Migrations Source: https://github.com/jeffersongoncalves/laravel-benefit/blob/main/README.md Publish and run the package migrations. ```bash php artisan vendor:publish --tag="benefit-migrations" php artisan migrate ``` -------------------------------- ### Create and Use Benefit Model Source: https://github.com/jeffersongoncalves/laravel-benefit/blob/main/README.md Shows how to create a Benefit with translatable fields and access translations. ```php use JeffersonGoncalves\Benefit\Models\Benefit; $benefit = Benefit::create([ 'name' => ['en' => 'Free Shipping', 'pt_BR' => 'Frete Grátis'], 'description' => ['en' => 'No shipping costs on any order.', 'pt_BR' => 'Sem custo de frete em qualquer pedido.'], 'slug' => 'free-shipping', ]); $benefit->name; // resolved for the current app locale, with fallback $benefit->getTranslation('name', 'pt_BR'); // 'Frete Grátis' $benefit->setTranslation('description', 'es', 'Sin costos de envío.'); $benefit->save(); ``` -------------------------------- ### Publish Config File Source: https://github.com/jeffersongoncalves/laravel-benefit/blob/main/README.md Publish the optional config file. ```bash php artisan vendor:publish --tag="benefit-config" ``` -------------------------------- ### Use Translatable API Methods Source: https://github.com/jeffersongoncalves/laravel-benefit/blob/main/README.md Demonstrates the spatie/laravel-translatable API methods available on the Benefit model. ```php $benefit->getTranslation('name', 'pt_BR'); $benefit->setTranslation('name', 'pt_BR', 'Frete Grátis'); $benefit->getTranslations('name'); // ['en' => '...', 'pt_BR' => '...'] $benefit->translate('name', 'pt_BR'); ``` -------------------------------- ### Run Tests Source: https://github.com/jeffersongoncalves/laravel-benefit/blob/main/README.md Runs the package test suite. ```bash composer test ``` -------------------------------- ### Configure Locales Source: https://github.com/jeffersongoncalves/laravel-benefit/blob/main/README.md Defines supported locales from app.available_locales or falls back to the app locale. ```php 'locales' => config('app.available_locales') ? array_keys(config('app.available_locales')) : [config('app.locale', 'en')], ``` -------------------------------- ### Configure Table Name Source: https://github.com/jeffersongoncalves/laravel-benefit/blob/main/README.md Configures the table name for the benefits table. ```php 'table_names' => [ 'benefits' => 'benefits', ], ``` -------------------------------- ### Route Model Binding with Slug Source: https://github.com/jeffersongoncalves/laravel-benefit/blob/main/README.md Shows route model binding using the slug column as the route key. ```php Route::get('/benefits/{benefit}', fn (Benefit $benefit) => $benefit); // resolves via the `slug` column ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.