Package Data | |
---|---|
Maintainer Username: | Fenzland |
Maintainer Contact: | uukoo@163.com (Fenz Yeah) |
Package Create Date: | 2016-11-01 |
Package Last Update: | 2017-09-27 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-19 03:13:37 |
Package Statistics | |
---|---|
Total Downloads: | 93 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 3 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 0 |
Some useful helper functions for laravel.
Step 1. Install with composer.
composer require fenzland/laravel-helpers
Step 2. Enjoy.
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())));
//*/
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');
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', ],
]