DALTCORE / laravel-useful-helpers by RamonSmit

Some useful helpers for the laravel framework
5,029
0
2
Package Data
Maintainer Username: RamonSmit
Maintainer Contact: ramon@daltcore.com (Ramon Smit)
Package Create Date: 2016-11-21
Package Last Update: 2023-08-15
Language: PHP
License: MIT
Last Refreshed: 2024-05-04 15:07:06
Package Statistics
Total Downloads: 5,029
Monthly Downloads: 22
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

laravel-useful-helpers

Some useful helpers for Laravel

Laravel 5.3/5.4/5.5/5.6/5.7 compatible

composer require daltcore/laravel-useful-helpers dev-master

Generate user friendly passwords

So use's are not confused anymore with some characters. This is a know problem with people who can't see correct.

/**
* Generate a password without i o 0 I l L etc.
**/
echo user_friendly_password($length = 9, $add_dashes = false, $available_sets = 'lud');

URL to Route name

Get the route name for the url that's given. Might be handy some times.

/**
* In case of named routes, you can use this function to transform the uri '/' to web.home.index
* @param null|string $uri    = '/'
* @param string      $method = 'GET'
**/
echo route_name(); // site.home.show
echo route_name(\URL::current()); // site.home.show
echo route_name('cms/user/1/delete', 'DELETE'); // cms.user.delete

Check if the given route name match the current route name

Just give a string and a boolean will be returned if the given route name has a match for the current route name.

/**
 * Check if the given route name is or are the same as the current route
 *
 * @param  string $route
 * @return boolean
 */
if (active_route('cms.post.*')) { ...

Check if the given URI match the current URI

You have two options:

  • Check if the given URI matches only a part of the current URI
  • Check if the given URI matches the current URI exactly
/**
 * Check if the current uri contains the given uri
 *
 * @param  string  $uri
 * @param  boolean $strict
 * @return boolean
 */
if (activeUri('posts')) { ...
if (activeUri('posts', true)) { ...