Skip to content

Instantly share code, notes, and snippets.

View helmerdavila's full-sized avatar
🏠
Working from home

Helmer helmerdavila

🏠
Working from home
View GitHub Profile
//donde se pone la vista se genera una ruta
Route::group(['middleware' => 'auth'], function () {
Route::get('{view}', function ($view) {
try {
return view($view);
} catch (\Exception $e) {
abort(404);
}
})->where('view', '.*');
@helmerdavila
helmerdavila / collection_filter_and_merge.php
Last active August 29, 2015 14:27
Collection Filter and Merge
<?php
public function list(Request $request)
{
$filtering = new Collection;
Expenditure::with('type', 'concept', 'store')
->chunk(200, function ($listExpenditures) use (&$filtering, $request) {
if ($request->has('startDateRange') && $request->has('endDateRange')) {
$startDate = Carbon::createFromFormat('Y-m-d', $request->input('startDateRange'));
@helmerdavila
helmerdavila / blade_var.php
Created September 10, 2015 00:36
Set variable in blade without php tags
{{--*/ $test = 'string_var' /*--}}
@helmerdavila
helmerdavila / test_guide.xml
Created October 19, 2015 04:48
Separate folders for PhpUnit Laravel Test
// phpunit.xml
<testsuites>
<testsuite name="unit">
<directory>./app/tests/unit/</directory>
</testsuite>
<testsuite name="integration">
<directory>./app/tests/integration/</directory>
</testsuite>
</testsuites>
@helmerdavila
helmerdavila / Database Change Test.xml
Created October 19, 2015 05:05
Change DB Enviroment For test
// install sqlite
// sudo apt-get install sqlite3
// install php extension
// sudo apt-get install php5-sqlite
// en phpunit.xml
<env name="DB_CONNECTION" value="sqlite">
@helmerdavila
helmerdavila / string_with_spaces_validator.php
Created November 6, 2015 06:05
Validador Cadena con espacios Laravel
<?php
// Colocar en AppServiceProvider o en Provider a gusto
Validator::extend('alpha_spaces', function($attribute, $value)
{
return preg_match('/^[\pL\s]+$/u', $value);
});
@helmerdavila
helmerdavila / laravel_test_tricks.php
Last active November 24, 2015 22:18
Laravel Testing Tricks
<?php
// Submit form with data
public function test_login_form()
{
$this->visit('/login')
->submitForm('Log In', ['email' => '[email protected]', 'password' => 'secret'])
->see('Welcome!')
->onPage('dashboard');
}
@helmerdavila
helmerdavila / orbis_prueba.php
Created February 9, 2016 04:01
Prueba Orbis
<?php
/**
* Averiguar ######, que es la sumatoria de los 12 numeros primos capicúas de
* 5 cifras que solo usen 2 digitos, uno par y el otro impar
* (ejemplos de estos numeros: 11411, 72727, 78887)
*/
function es_primo($numero)
{
$divisores = 0;
@helmerdavila
helmerdavila / helper_fecha.php
Created March 17, 2016 16:21
Helper para fecha a español
<?php
if (!function_exists('formato_fecha')) {
function formato_fecha($time = null)
{
$dias = ["Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sábado"];
$meses = [
"Enero",
"Febrero",
"Marzo",
@helmerdavila
helmerdavila / 0_reuse_code.js
Created December 9, 2016 16:17
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console