Skip to content

Instantly share code, notes, and snippets.

View validate-bi.js
export const validateBI = function (NBI, checkDigit) {
return {
valid: validateBI(NBI, checkDigit),
errorMessage: 'BI não válido'
const NBI_LENGTH = 9
View test-cc.js
export const validateCC = function (value) {
return {
valid: validate(value),
errorMessage: 'O número do Cartão de Cidadão não é válido'
const CHAR = {
'0': 0,
'1': 1,
View nif-validator.js
export const validateNif = function (value) {
return {
valid: validateNIF(value),
errorMessage: 'NIF não válido'
function validateNIF (value) {
if (!/[123]\d{8}/.test(value)) {
return false
lavary /
Last active Aug 29, 2015
Passing data to views without using sequential with() methods in Laravel 4

Python has a nice built-in function named locals() which returns a dictionary of local symbol table. This makes it easy to pass local variables to views in a single move.

I was wondering if PHP has such nice feature. I searched PHP's documentation and found this familiar built-in function: get_defined_vars()

get_defind_vars() Returns an array of all defined variables within the current scope.

Since PHP 5.0.0, the $GLOBALS variable is included in the results of the array returned.

You can use get_defind_vars() in a controller,closure or anywhere else you need:

lavary /
Last active Jun 17, 2018
Making multiple menus in a Bootstrap navbar

#Laravel Menu: Bootstrap Navbar

It is possible to create multiple menu instances in a single navbar. I'm going to use Bootstrap default navbar for this demonstration:

First of all we create our menu objects in app/routes.php or app/start/global.php or any other place you desire as long as it is auto loaded when a request hits your application.