Download the PHP package fomvasss/laravel-str-tokens without Composer
On this page you can find all versions of the php package fomvasss/laravel-str-tokens. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fomvasss/laravel-str-tokens
More information about fomvasss/laravel-str-tokens
Files in fomvasss/laravel-str-tokens
Package laravel-str-tokens
Short Description A package to manage and generate string with tokens/shortcodes for Eloquent Models
License MIT
Homepage https://github.com/fomvasss/laravel-str-tokens
Informations about the package laravel-str-tokens
Laravel Str Tokens
With this package you can manage & generate strings with tokens/shortcodes, it seems like CMS Drupal.
Installation
Run from the command line:
To publish the configs, run the following command:
Configuration file will be publish to config/str-tokens.php
Configuration
The configuration fill will allow you to control how tokens are parsed using token_match_pattern
and token_split_character
You can decide if a token can traverse eloquent model relationships using can_traverse_relations
You can globally limit what model fields are allowed as tokens using disable_model_tokens
You can also limit what tokens are exposed via individual models by creating a strTokenWhitelist
or strTokenBlacklist
function that returns an array of valid patterns
Usage
Given result:
You can use method setEntities()
for set many Eloquent models, for example:
Defining custom tokens in Eloquent models
In your models you can create own methods for generate tokens.
The names of these methods must begin with strToken
.
In next example, we create custom methods: strTokenTest()
, strTokenCreatedAt()
And now we can use next token in string:
And result:
Example Article
Eloquent model:
Example Term
model:
Use in blade template
Changelog
Please see CHANGELOG for more information on what has changed recently.
Links
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-str-tokens with dependencies
illuminate/support Version ^9.0|^10.0|^11.0|^12.0
nesbot/carbon Version ^2.0|^3.0