A bunch of functions that can help

Installs: 225

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 1

Open Issues: 1


v1.9.9.6 2020-03-27 02:34 UTC


This package has a few php helpers, for everyday tasks


This packages requires Spatie/Analytics for the charts You can install the package via composer:

$ composer require maksuco/Helpers
$ composer require maksuco/Helpers:dev-master

This Package works with auto discovery in Laravel +5.5, but is compatible with older versions



use Illuminate\Support\Facades\Helpers;

Device check: Mobile, Tables, Desktop

Response with the correct device, example: (300,'table',200), the response is 300 when is mobile OR 200 if it's desktop. ('mobile','table','desktop')


Check if device is Mobile

  //Returns true or false

Check if device is Mobile, Operating System and Browser

  //Returns Array ( [desktop] => 1 [mobile] => [tablet] =>  [device] => desktop [browser] => Chrome [os] => Macintosh [result] => Macintosh Chrome )


This function helps you show the user avatar or the gravatar, just send the user array or email. It returns the image path or base64

  $img = \Helpers::avatar($user);

First Name

Helps you show the user first name, from a full name, max length of the returned name is 11

  //Gina Gutierrez returns Gina
  //Gi Gutierrez returns Gi Gutierrez

Name Initials

  //SEND Sofia Loren
  //GET SL


Here's an example of how to implement crypto to transform strings to hashed keys, using 2 security keys: one set in the .env (CRYPTO_STRING) and another inside the controller, example the $user->id:

  $security = Helpers::encrypt($string,$key);
  $string = Helpers::decrypt($string,$key);

Active Navigation Page

Send the current page name, example 'about' or 'contactenos', it checks if theres a variable named $active (send from the controller) then checks if the route has a name and then checks the first segment of the page, example: about/history

  //SEND: nav_active('about')
  //RETURNS: 'active'

Text parser

Convert plain text to include real html links

  //SEND: Welcome to http:://
  //RETURNS: Welcome to <a href="http:://">http:://</a>

Find text between 2 strings

Returns an array with all results


Get all countries

A list of countries to show in a select

  //RETURNS: Array
  //RETURNS: "id": 241,"code": "US","name_en": "United States","name_es": "Estados Unidos","status": null,"tel": 1,"lang": "en","currency": "USD","currency_symbol": "$","timezone_group": null

Get all timezones

A list of timezones to show in a select

  //RETURNS: Array

Get all languages or lang code name

  //RETURNS: Array
  //RETURNS: 'english'

Get all currencies or currency details for echo

A list of countries to show in a select or currency details like symbol, decimals, name, etc..

  //RETURNS: Array of isoCodes
  //RETURNS: Array of all currencies with: name, isoCode, symbol and other data
  //RETURNS: All data of the currency
  //'10000.00','usd' RETURNS: $10,000 usd
  //'100.30','usd' RETURNS: $100.30 usd
  //'10000.30','eur' RETURNS: 10.000,30 €
  //'10000.00','cop',true RETURNS: Array ["result" => "$10.000""symbol" => "$""htmlEntity" => "&#x20B1;""amount" => "10.000""isoCode" => "COP""symbolFirst" => true"decimalSeparator" => ",""thousandsSeparator" => "."]

Money Format

  //SEND: 1234.56,'EUR' RETURNS: €1,234.56
  //SEND: 1234.00,'USD' RETURNS: $1,234

Decimal Format

Useful for saving numbers on mysql decimal columns

  //SEND: 1,234.56 RETURNS: 1234.56
  //SEND: 1,234 RETURNS: 1234.00

Location GEOIP

Get the city, country, language and other data from the IP: This product includes GeoLite2 data created by MaxMind, available from

  $location_data = \Helpers::geoip($ip); //\Helpers::geoip($ip,'isp');

if you need the function to provide the ip, just put null in the $ip. if you also want the isp info, just include the second call.

Date in IP TimeZone


Location distance between 2 points

The units is optional, default is "miles"

  $distance = \Helpers::distance($lat1, $lon1, $lat2, $lon2, $unit = "K");

Append to json (only works with first level for now)

Send new data to append to a json data or subcategory (subcategory and limit are optional).

You send the DB column as $json, the new object or array as $new.


LImit, sets a limit for the amounts of records

Modify csv string action=add,remove,check

Send id's to add, remove or check if exist in csv string


Modify array with action=add,remove,check

Send new data to add, remove, check if exist in array or invert Works with Sequential and Associative arrays Invert adds the new if doesn't exist, or removes it if exist and returns the action "added" or "removed"


	//$array = ['michael','gina'];
  //array_process('add',$array,'bob') returns ['michael','gina','bob']

  //array_process('remove',$array,'michael') returns ['gina']

  //array_process('invert',$array,'michael') returns "removed" MALLLLLLl
	//$array = ['michael'=>'m'];
	//$new = ['michael'=>'something','donald'=>'duck','bob'=>'m'];
  //array_process('add',$array2,$new2) returns ['michael'=>'something','donald'=>'duck','bob'=>'m']
	//array_process('check',$array,'gina') returns TRUE

Collection Relations Append

Include in a collection the columns from another table with just one extra query $principal_relation_column = the principal reference INT, typically id (This is optional)

Examples: ($user,$post,'user_id',['post_name'=>'name'])


Column: Array and Json check

Check if a value is in a column (Works with json, array and string explode) //only 1 level RETURNS: true or false

  {{(\Helpers::column_check($data,$value))? 'YES!':'NO!'}} //($user->favorites,124)

Column Process (if is in column, it will delete it, if not it will add it)

  \Helpers::column_process($data,$table,$column,$value) //($user,'users','favorites',124)


Check if a domain doesn't have the http and adds it, and other links, domains helpers

  $domain = \Helpers::domain_from_email($email);
  //returns the domain from an email if it's not a free service like, else it returns false

Transform number to telto number

  //SEND: +1 (305) 890 8989
  //RETURNS: 13058908989

Email and Domain Check

  if(\Helpers::email_check($email)) {}
  //returns if the email is valid: true or false
  //Also checks if the domain exist

  if(\Helpers::domain_check($email)) {}
  //returns the domain from the email and checks if it exist
  if(\Helpers::domain_check('')) {}
  //Checks if the domain exist

File size to bytes calculator

Send '1 mb' and get the result in bytes, send measurements in: b, kb, mb, gb, tb

  \Helpers::sizetobytes('1 mb');
  //returns xxxx bytes

Generate random string

Send the length of the random

  //returns xxxx
  //if you want only numbers

Filename Parsing

Get a filename name from a string or url, you can also parse it and get basename, extension and filename

  $filename = \Helpers::filename('');
  //RETURNS: this_is_the_name.png
  $filename = \Helpers::filename('',true);
  //RETURNS ARRAY: basename: this_is_the_name.png, extension: png, filename: this_is_the_name
  //USE: $filename->basename


Here's an example of how to implement the slug function to transform names to slugs:

  $slug = \Helpers::slug('Hi how are you? Muy@#$%^&*good');
  //RETURNS: hi-how-are-you-muy-good
  $slug = \Helpers::slug($name);

Transform file names, the second argument specifies a random addon at the end, can be text or INT

  $slug = \Helpers::slug_file('Hi how are you? Muy@#$%^&*good.jpg',0);
  $slug = \Helpers::slug_file($file->getClientOriginalName(),5);
  $slug = \Helpers::slug_file($filename,'great-doc');

In this function you can specify a new filename (REPLACE) and use the same extension

  $slug = \Helpers::slug_filename('SomeFile.jpg','new-name',0);
  $slug = \Helpers::slug_filename($file->getorriginalname(),'new-image',2);
  $slug = \Helpers::slug_filename($file,'one','great-images');

Here's an example of how to implement the random function, Adds random at the end of the file name, and checks if its numeric or string

  $slug = \Helpers::slug_random('new-image');

Social Sharing

$url can be null to automatically get the current url page

Facebook Share

$app_id is optional


Twitter Share

$username is optional


LinkedIn Share

$username is optional


Pinterest Share

$image is optional


Whatsapp Share


Whatsapp Chat

  //\Helpers::whatsappchat('15551234xxx',null,'Im interested in your service')

ADD POPUP INSTEAD OF target="_blank"

Just add to the link onclick="return popup(this);"

  onclick="return popup(this);"




Requires composer require raiym/instagram-php-scraper

  $media = \Helpers::instagram_process($instagram,'username');

VeeValidate Honeypot

Renders a vee validate html and css honeypot:


Form input example with css error (cross)

<div class="form-group">
  <label for="email">Email address</label>
  <input type="email" class="form-control" id="email" placeholder="Enter email" v-validate="'required|email'" name="email" :class="{'form-control-invalid': errors.has('email')}">
  <small class="form-text text-danger">@{{errors.first('email')}}</small>

Vue code example

Vue.use(VeeValidate); // good to go.
new Vue({
  el: '#formVee',
  data: {
    submit_text: "{{__('Submit')}}",
    time: 0
  created () {
    setInterval(() => { this.time++;}, 1000);
  methods: {
    validateBeforeSubmit: function(e){
      this.$validator.validateAll().then((result) => {
        if(result) {
          if(this.time < 3) { alert('bot!!!');location.reload(); }
          this.submit_text = "<i class='far fa-circle-notch fa-spin'></i>";
          setTimeout(function(){ document.querySelector('#formVee').submit(); }, 500);