oblak / vocative-laravel
This is my package vocative-laravel
Fund package maintenance!
seebeen
Requires
- php: ^8.1
- illuminate/contracts: ^10.0
- oblak/vocative: ^1.0@alpha
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- larastan/larastan: ^2.0.1
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.8
- orchestra/testbench: ^8.8
- pestphp/pest: ^2.20
- pestphp/pest-plugin-arch: ^2.5
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
This package is auto-updated.
Last update: 2025-05-21 13:48:59 UTC
README
Larative 🗣️
Vocative Service Provider for Larative
This library allows you to effortlessly convert Serbian personal names to their correct vocative form in your Laravel application.
Installation
You can install the package via composer:
composer require oblak/vocative-laravel
You can publish the config file with:
php artisan vendor:publish --tag="vocative-config"
This is the contents of the published config file:
<?php return [ 'dictionary' => [], 'ignore_dictionary' => false, ];
Usage
You can use the package in your application by calling the Vocative
class directly or using the provided Blade directives.
Using the Facade
You can use the Vocative
facade to transform names to their vocative form:
use Oblak\Vocative\Facades\Vocative; // Transform a name to vocative case echo Vocative::make('Милица'); // "Милице" echo Vocative::make('Марко'); // "Марко" // Force transformation (bypass dictionary) echo Vocative::make('Лука', true); // Forces transformation even if in dictionary
Using Blade Directives
The package provides two Blade directives for convenient use in your templates:
{{-- Using @vocative directive --}} Hello, @vocative('Милица')! {{-- Using the shorter @voc alias --}} Hello, @voc('Марко')!
Custom Dictionary
You can define custom vocative forms in the configuration file:
// config/vocative.php return [ 'dictionary' => [ 'CUSTOM_NAME' => 'CUSTOM_VOCATIVE_FORM', 'Лука' => 'Луко', ], 'ignore_dictionary' => false, // Set to true to always force transformation ];
Testing
composer test
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.