Skip to content

Instantly share code, notes, and snippets.

@praisedare
praisedare / php.ini
Created December 11, 2023 20:16
xdebug config
# Location of xdebug extension (will probably differ on your own system)
zend_extension=/usr/local/lib/php/pecl/20220829/xdebug.so
# Enable Xdebug
xdebug.mode=debug
xdebug.remote_port=9003
xdebug.start_with_request=true
xdebug.remote_enable=On
xdebug.discover_client_host=true
xdebug.remote_connect_back=On
function hash(string) {
const utf8 = new TextEncoder().encode(string);
return crypto.subtle.digest('SHA-256', utf8).then((hashBuffer) => {
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashHex = hashArray
.map((bytes) => bytes.toString(16).padStart(2, '0'))
.join('');
return hashHex;
});
}
<?php
trait EnumerableConstants
{
static function values()
{
return array_values (
(new \ReflectionClass(static::class))->getConstants()
);
}
<?php
/**
* Adds a static `values` method that returns an array
* containing the values of a backed enum
*/
trait ListableEnumValues
{
static function values(): array
{
<?php
Builder::macro('whereLike', function ($attributes, string $searchTerm) {
$this->where(function (Builder $query) use ($attributes, $searchTerm) {
foreach (Arr::wrap($attributes) as $attribute) {
$query->when(
str_contains($attribute, '.'),
function (Builder $query) use ($attribute, $searchTerm) {
$relations = explode('.', $attribute);
$is_top_level_relationship = true;