An utilities package for Laravel 11+, it includes various categories of useful methods to ease the life of a developer and speed up the process.
To use the old system with a single Utils class, use the versions v1.x or use the v1 branch
An easy way to make AB tests based on variants.
Gets the variant for the model (Either 1 or 2) based on their primaryKey. Use the salt to have different outcomes for different tests
Example:
$model = \App\Models\User::find(1);
$variant = \LiveControls\Utils\AB::getVariantForModel($model, 'feature_a');
dd($variant); //Returns either 1 or 2Check if the Model is inside the selected variant based on their primaryKey. Use the salt to have different outcomes for different tests
Example:
$variant = 1; //Can also be A or 2/B
$model = \App\Models\User::find(1);
$hasVariant = hasVariant($model, $variant, 'feature_a');
dd($hasVariant); //Would return true if model is inside variant with the selected saltAn array helper to add some functions that are present in Laravel collections, but not in PHP arrays and more.
Contains helpers to convert BBCodes.
Contains helpers to make it easier for creating blogs.
Contains methods to handle CSV files like import, export and more.
Contains helpers to handle Files like get their Mimetypes and more.
Contains helpers to handle numbers with ease.
Several methods that do not fit into other categories.
Contains helpers to handle brazilian social security numbers.
Contains helpers to manipulate strings.
Contains helpers to Carbon time objects and more.
Contains several types of brazilian social security numbers to ease their check and manipulation. Is used by the SocialSecurity class.
An exception that can be used in testing to show deprecated methods.
An exception that can be used to show not implemented methods.
A trait that will handle AB tests for Laravel models.
In your Model add the following:
use \LiveControls\Utils\HasABTests;You can then use it the following:
$model = \App\Models\User::find(1);
$variant = 1; //Can be either 1/A or 2/B
$salt = 'feature_1'; //Can be a name of the feature you want to check or can be leave out to have it general.
$model->hasVariant($variant, $salt); //Will return true if its the models variant
$model->getVariantForModel($salt); //Returns either 1 or 2, depending on the models variant.
$model->has_variant_a; //Returns true if model has variant a. Does not support a salt.
$model->has_variant_b; //Returns true if model has variant b. Does not support a salt.