calebporzio / awesome-helpers Goto Github PK
View Code? Open in Web Editor NEWHelper functions I find super-duper handy
Helper functions I find super-duper handy
It would be great to add support for insert, update, delete queries to dump_sql it works really fine for select statements.
ej.
dump_sql(DB::table('customers')->insert(['name' => 'Caleb']));
thanks!
I want to use this but I get errors where they conflict with my own implementations:
Cannot redeclare connection() (previously declared in ...vendor/calebporzio/awesome-helpers/src/helpers/connection.php:3)
As per the usual convention:
https://github.com/laravel/helpers/blob/1c3c128fa96bad2bc338eab1823fe7372e0c5328/src/helpers.php#L6
<?php
+if (! function_exists('array_add')) {
/**
* Add an element to an array using "dot" notation if it doesn't exist.
*
* @param array $array
* @param string $key
* @param mixed $value
* @return array
*/
function array_add($array, $key, $value)
{
return Arr::add($array, $key, $value);
}
+}
I'm happy to open a PR if you'll consider it.
PHP 7.2 may break some projects after the change of count() function, throwing warning (futuraly will be an error). When receiving parameters that aren't array or countable objects.
I have created a helper to treat this problem, not a good practice, but for upgrading large projects it can be used temporarily.
Do you guys consider this helper a good addition for awesome-helpers?
When I run tinker(['id', 'title', 'description', 'completed_at', 'category']);
, it gives me;
ErrorException
array_combine(): Both parameters should have an equal number of elements
at vendor/illuminate/support/Collection.php:725
721| * @return static
722| */
723| public function combine($values)
724| {
> 725| return new static(array_combine($this->all(), $this->getArrayableItems($values)));
726| }
727|
728| /**
729| * Union the collection with the given items.
+1 vendor frames
2 app/Commands/TaskList.php:38
Illuminate\Support\Collection::combine()
3 app/Commands/TaskList.php:81
App\Commands\tinker()
Version info;
$ composer show | grep laravel
laravel-zero/foundation v7.4.0 This is a mirror from illuminate/foundation.
laravel-zero/framework v7.2.1 The Laravel Zero Framework.
laravel/tinker v2.3.0 Powerful REPL for the Laravel framework.
$ composer show | grep caleb
calebporzio/awesome-helpers v2.4.5 Helper functions I find super-duper handy
$ php -v
PHP 7.4.6 (cli) (built: May 14 2020 10:03:07) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.6, Copyright (c), by Zend Technologies
with Xdebug v2.9.5, Copyright (c) 2002-2020, by Derick Rethans
I missed having the "left" function of c#, and the right function has been super helpful for things.
On the "right" function, I have allowed a user to pass in a positive or negative value. If they pass a positive, then I multiply it by negative 1 to get the correct format.
function left($original, $characters)
{
if (!$original || !$characters) {
return null;
}
return substr($original, 0, $characters);
}
function right($original, $characters)
{
if (!$original || !$characters) {
return null;
}
if ($characters > 0) {
$characters *= -1;
}
return substr($original, $characters);
}
Some of the other popular money packages has a money helper function as well. Might want to rename the money() function here.
Examples:
https://github.com/akaunting/money
https://github.com/cknow/laravel-money
Psy shell is used but psy/psysh is not required.
Hey,
Are the PR about Collection macros acceptable?
I tried money(35.55)
=> This showed me ¤35.88
.
Why this issue?
awesome-helpers uses auth()
which resides in laravel/framework but that packages is not required
Please advise.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.