Download the PHP package marshmallow/helpers without Composer
On this page you can find all versions of the php package marshmallow/helpers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download marshmallow/helpers
More information about marshmallow/helpers
Files in marshmallow/helpers
Package helpers
Short Description A package containing all the helper function we can use throughout all our projects
License MIT
Homepage https://github.com/Marshmallow-Development/
Informations about the package helpers
Marshmallow Deployer
We have build a package with some helpers that are usefull in almost every project. We use this package in all our projects. For ourself and for our customers. If you miss anything, create an issue and will will add it as soon as possible.
Installation
You can install the package via composer:
Table of contents
- CSV Helper
- Helper functions
- String helper
- Migrations
- URL
- Array
- Reviews
- Grouper
CSV Helper
This helper will make generating .csv files extremly ease. Please check the examples below. You can use the store method to store it in a location of your choosing. You can use the download method if you just want to download the file. If you wish to store and download the generated .csv file you can use the storeAndDownload method.
Usage example
Use a collection as data attribute
You can use a collection as your data attribute. By default it will map all the data in the collection sequence. If you wish to edit the collection data, you can add a callback method to the data method. Please note that this will give you every row as an array
value.
Store and download calls
The following methods are available for storing and downloading the generated csv file.
Helper functions
Percentage helper
This is a public helper function that is available within your Laravel application. This function can be used in all your PHP and Blade files.
String Helper
The Str helper extends the helper from Laravel. So you have all the methods available in the Laravel helper available as well. Check the Laravel documentation for all the available methods.
Str::join()
This method is super handy for concatenating strings separated by a comma, but use another value for the last item. Checkout the example below.
Str::random()
We have added on the default Str::random()
of Laravel. We've added a second parameter which is an array of characters that should be ignored. We also have build in a couple of presets like lowercase
which will make sure the random string won't contain any lowercase characters.
Str::cleanPhoneNumber()
Str::phonenumberWithCountryCode()
Return a cleaned phonenumber with the country code. You can choose to return the phonenumber with a +
or 00
at the start of the phonenumber.
Str::numbersOnly()
Str::numbersAndLettersOnly()
Str::readmore()
Str::paragraphsAsArray()
Str::getFirstParagraph()
Str::getAllButFirstParagraph()
Migrations
We have a trait available that gives you some extra options when creating migrations. Add the MigrationHelper
trait to you migration to make use of these options.
Implementation
Create a column only if it doesn't exist.
This method was added because when a database that already has a products table and later will use our Product
package, the migrations will through error's.
URL
URL::isInternal()
URL::isCurrent()
URL::buildFromArray()
URL::isNova()
URL::isNotNova()
Array
Arrayable::storeInFile();
This method will store a pretty array in a file. With this method is possible to generate config files.
Builder
Builder::published()
BuilderHelper::published
will filter on database columns if something is published.
Reviews
For the review stars you can call ReviewHelper::ratingToStars(4.5)
. By default the ReviewHelper will think you are using a max rating of 5, support half star rating and return a string of FontAwesome icons. You can overule this behaviour by;
Customise
Create the config file config/review.php
and specify your needs:
Or you can provide the same config array as a second parameter to the ratingToStars
method like so;
Grouper
Grouper is a super handy helper when you need to split your queries results in to groups. We use this with blogs a lot. The first row might have 3 results, the second row will have 1 result, en the third row will have 3 items again. Please see the example below.
As you can see in the example, the structure_array
has a name as the key. This is done so when you are looping through your groups, you are able the test which group you are currently looping.
Looping through the group items works just like you expect when working with collections.
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of helpers with dependencies
laravel/helpers Version ^1.3
illuminate/database Version ^8.0|^9.0|^10.0|^11.0
illuminate/support Version ^8.0|^9.0|^10.0|^11.0