Skip to content

Instantly share code, notes, and snippets.

<?php
namespace App\Models\Traits;
use Illuminate\Contracts\Database\Eloquent\Builder;
trait OrderByArrayScope
{
public function scopeOrderByArray(Builder $query, string $key, array $values, string $direction = 'ASC', bool $prefix = true)
{
@godismyjudge95
godismyjudge95 / useCustomForm.ts
Created July 30, 2023 18:46
A custom wrapper for Hybridly's useForm helper that enables autosubmitting and autosaving (via LocalStorage)
import { SearchableObject, Path } from '@clickbar/dot-diver';
import { UnwrapRef } from 'vue';
export const defaultAutosaveDebounce = 750;
export const defaultAutosubmitDebounce = 750;
type FormOptions<
T extends SearchableObject,
P extends Path<T> & string = Path<T> & string,
> = Parameters<typeof useForm<T, P>>[0];
@godismyjudge95
godismyjudge95 / transform_pk_int_to_bigint.php
Created June 22, 2023 18:49
A Laravel migration to convert the primary keys from int to bigint
<?php
use Illuminate\Database\Migrations\Migration;
use Doctrine\DBAL\Schema\AbstractSchemaManager as DoctrineSchemaManager;
use Doctrine\DBAL\Types\IntegerType;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder as SchemaBuilder;
use Symfony\Component\Console\Output\ConsoleOutput;
/**
@godismyjudge95
godismyjudge95 / mapbox-gl-draw.js
Created March 2, 2019 08:06
Mapbox GL Draw Click Propagation Fixed Build
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.MapboxDraw = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";
var runSetup = require('./src/setup');
var setupOptions = require('./src/options');
var setupAPI = require('./src/api');
var Constants = r
@godismyjudge95
godismyjudge95 / detect-gl.js
Created February 20, 2019 19:46
Detecting gl properly in modern browsers
var canvas = document.createElement("canvas");
try { gl = canvas.getContext("webgl"); }
catch (x) { gl = null; }
if (gl == null) {
try { gl = canvas.getContext("experimental-webgl"); experimental = true; }
catch (x) { gl = null; }
}
gl = !!gl;