This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** This plugin replaces UNIX timestamps with human-readable dates in your local timezone. | |
* Mouse click on the date field reveals timestamp back. | |
* | |
* @link https://www.adminer.org/plugins/#use | |
* @author Anonymous | |
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 | |
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other) | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // app/Http/Traits/ClosureTable.php | |
namespace App\Models\Traits; | |
use Exception; | |
use Illuminate\Database\Eloquent\Model; | |
use Illuminate\Database\Eloquent\Relations\BelongsToMany; | |
use Illuminate\Support\Facades\Db; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function numberToMetric(int|float $number, int $significantDigits = 3, bool $binary = false): string { | |
static $prefixes = ['y','z','a','f','p','n','μ','m','','k','M','G','T','P','E','Z','Y']; | |
$factor = floor((strlen(abs($number)) - 1) / 3) * (abs($number) <=> 1); | |
$metricBase = $binary ? 1024 : 1000; | |
$number = $number / pow($metricBase, $factor); | |
return sprintf("%.{$significantDigits}H", $number) . $prefixes[$factor+8]; |