Skip to content

Instantly share code, notes, and snippets.

View nuernbergerA's full-sized avatar
🐙
spreading my tentacles

Adrian Nürnberger nuernbergerA

🐙
spreading my tentacles
View GitHub Profile
@nuernbergerA
nuernbergerA / 1.php
Created November 8, 2024 21:24
4-a-a-ron
<?php
namespace App\Providers;
use Illuminate\Database\Connection;
use Illuminate\Database\Connectors\ConnectionFactory;
use Illuminate\Support\ServiceProvider;
use App\Database\CustomConnection;
class CustomDatabaseServiceProvider extends ServiceProvider
\Illuminate\Support\Collection::macro('sortByList', function (iterable $orderList, ?string $property = null) {
return $this
->sortBy(function($item) use ($property, $orderList) {
$value = $item;
if (is_iterable($item)) {
$value = $item[$property];
}
if (is_object($item)) {
@nuernbergerA
nuernbergerA / ProgressExample.php
Created February 19, 2024 15:53
Livewire v3 wire:stream Example
<?php
use Livewire\Component;
class ProgressExample extends Component
{
public function process() {
$progress = 0;
do {
@nuernbergerA
nuernbergerA / OgImageController.php
Created December 22, 2023 15:13
OgImageController
<?php
namespace App\Http\Controllers;
use App\Models\PhpFunction;
use Intervention\Image\AbstractFont;
use Intervention\Image\Facades\Image;
class OgImageController
{
@nuernbergerA
nuernbergerA / InteractsWithConsole.php
Created March 27, 2020 16:48
expectsQuestionWithAutocomplete
<?php
namespace Illuminate\Foundation\Testing\Concerns;
use Illuminate\Console\OutputStyle;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Support\Arr;
use Illuminate\Testing\PendingCommand;
trait InteractsWithConsole
@nuernbergerA
nuernbergerA / parse_phpinsights.php
Created May 31, 2019 14:53
Parse phpinsights output to checkstyle xml
<?php
$input = file_get_contents('php://stdin');
$headerPattern = '/• \[(.+)\] (.+): \((.+)\)/';
$linePattern = '/ (.+):(\d+): (.+)/';
$severity = 'error';
$source = '';
$message = '';
#!/bin/bash
# Prepend git commit messages
#
# Given we have a branch called 'feature/PHP-1337-awsome-stuff'
# every commit message will automatically be prepend with '[PHP-1337] '
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
<?php
/*
//Normal query
User::all();
//Cached query (default 60min)
User::cached()->all();
//Cached query (5min)