Skip to content

Instantly share code, notes, and snippets.

View innocenzi's full-sized avatar
🦋

Enzo Innocenzi innocenzi

🦋
View GitHub Profile
@innocenzi
innocenzi / RoutesTest.php
Created September 20, 2022 15:35
No closure route assertion
<?php
use Illuminate\Routing\Route;
use Illuminate\Routing\Router;
test('basic feature test', function () {
$routes = collect(app(Router::class)->getRoutes()->getRoutes())
->filter(fn (Route $route) => ! isVendorRoute($route));
foreach ($routes as $route) {
@innocenzi
innocenzi / app.ts
Last active January 24, 2023 09:52
Inertia reload plugin PoC
import { createApp, h } from 'vue'
import { createInertiaApp, router } from '@inertiajs/vue3'
// This virtual import adds the HMR code to the client
import 'virtual:inertia/reload'
// This persists the router to `window`, can't think of another way unfortunately
window.inertia = { router }
// Alternatively you could just have the "client code" here, but the packagability would be worse
createInertiaApp({
<?php
/**
* @template T
* @param T $target
* @return T
*/
function memoize($target) {
static $memo = new \WeakMap();
@innocenzi
innocenzi / migration.php
Last active September 28, 2023 22:35
Querying direct and indirect relations in a many-to-many table
<?php
Schema::create('media', function (Blueprint $table) {
$table->id();
$table->string('native_title')->index();
// ...
$table->timestamp('published_at');
$table->timestamps();
});
@innocenzi
innocenzi / response.txt
Created March 31, 2025 19:33
dd response
<script> Sfdump = window.Sfdump || (function (doc) { doc.documentElement.classList.add('sf-js-enabled'); var rxEsc = /([.*+?^${}()|\[\]\/\\])/g, idRx = /\bsf-dump-\d+-ref[012]\w+\b/, keyHint = 0 <= navigator.platform.toUpperCase().indexOf('MAC') ? 'Cmd' : 'Ctrl', addEventListener = function (e, n, cb) { e.addEventListener(n, cb, false); }; if (!doc.addEventListener) { addEventListener = function (element, eventName, callback) { element.attachEvent('on' + eventName, function (e) { e.preventDefault = function () {e.returnValue = false;}; e.target = e.srcElement; callback(e); }); }; } function toggle(a, recursive) { var s = a.nextSibling || {}, oldClass = s.className, arrow, newClass; if (/\bsf-dump-compact\b/.test(oldClass)) { arrow = '&#9660;'; newClass = 'sf-dump-expanded'; } else if (/\bsf-dump-expanded\b/.test(oldClass)) { arrow = '&#9654;'; newClass = 'sf-dump-compact'; } else { return false; } if (doc.createEvent && s.dispatchEvent) { var event = doc.createEvent('Event'); event.initEvent('sf-dump-expanded