fenzland / laravel-helpers
Helper functions for laravel.
1.0.0
2017-09-27 08:01 UTC
Requires
- php: >=7.0
- fenzland/php-helpers: ^1.0
- illuminate/routing: >=5.0
- illuminate/support: >=5.0
This package is not auto-updated.
Last update: 2024-11-23 20:42:29 UTC
README
Some useful helper functions for laravel.
Usage
Step 1. Install with composer.
composer require fenzland/laravel-helpers
Step 2. Enjoy.
Functions
z()
If you dump something with dd(), the program will be terminated. Sometimes (or usually), that's not what we want. Instead of exit, z() will dump what you give and return it back. So you can dump values in your process without side effect.
/* $foo->doSomething($bar->someObject->someValue()); /*/ z($foo->doSomething(z(z($bar->someObject)->someValue()))); //*/
routo()
Similar with route(), but smarter.
// Case 1: In page foo.bar.projects.index , call routo('.show',[ 'project'=>$project, ]) === route('foo.bar.projects.show',[ 'project'=>$project, ]); // Case 2: In page foo.bar.projects.show with param [ project=>$project, ] routo('.edit') === route('foo.bar.projects.edit',[ 'project'=>$project, ]); // Case 3: In page Foo:foo.foo.foo routo(':bar') === route('Foo:bar');
array_transposition()
Transposition a matrix, whitch is an array of some array with same structure.
$fromArray= [ 'foo'=> [ 'foo1', 'foo2', 'foo3', 'foo4', ], 'bar'=> [ 'bar1', 'bar2', 'bar3', 'bar4', ], ] array_transposition($fromArray) === [ [ 'foo'=>'foo1', 'bar'=>'bar1', ], [ 'foo'=>'foo2', 'bar'=>'bar2', ], [ 'foo'=>'foo3', 'bar'=>'bar3', ], [ 'foo'=>'foo4', 'bar'=>'bar4', ], ]