Skip to content

Instantly share code, notes, and snippets.


Jonathan Reinink reinink

View GitHub Profile
reinink /
Last active Mar 12, 2021
// Option 1: Manually
this.$`/toggle-thing/${}`, {}, { preserveScroll: true })
<!-- Option 2: Inertia Link -->
<inertia-link :href="`/toggle-thing/${}`" preserve-scroll>Toggle</inertia-link>
reinink / AddressInput.vue
Last active Feb 17, 2021
Multiple v-models in Vue 3
View AddressInput.vue
<input type="text" :value="address" @input="$emit('update:address', $">
<input type="text" :value="city" @input="$emit('update:city', $">
<input type="text" :value="region" @input="$emit('update:region', $">
<input type="text" :value="country" @input="$emit('update:country', $">
<input type="text" :value="postal" @input="$emit('update:postal', $">
<script setup>
import { defineProps } from 'vue'
reinink / Model.php
Created Feb 5, 2021
Prevent relationship lazy-loading in Laravel
View Model.php
namespace App;
use Exception;
use Illuminate\Database\Eloquent\Model as Eloquent;
class Model extends Eloquent
public function getRelationshipFromMethod($name)
View InertiaServiceProvider.php
namespace App\Providers;
use Inertia\ServiceProvider;
use Illuminate\Http\Request;
class InertiaServiceProvider extends ServiceProvider
reinink / query.sql
Last active Jul 27, 2020
Text search across multiple tables using MySQL
View query.sql
left join
companies on = users.company_id
where ( like 'TERM%' or
first_name like 'TERM%' or
View natural_sort.sql
FROM devices
WHERE name IN (
'Apple iPhone 11',
'Apple iPhone 3G',
'Apple iPhone XR'
ORDER By name+0<>0 DESC, name+0, name;
View trim_leading_whitespace.php
function trim_leading_whitespace($code)
$lines = collect(explode("\n", $code));
$min = collect(explode("\n", $code))->filter(function ($line) {
return trim($line);
})->min(function ($line) {
return strlen($line) - strlen(ltrim($line));
View nulls_last_tweet.html
<!DOCTYPE html>
<title>Nulls Last</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="^1.0/dist/tailwind.min.css" rel="stylesheet">
<body class="antialiased leading-none">
<div class="flex w-full p-24 bg-gray-300">
reinink / DateInput.vue
Created Aug 27, 2019
Pikaday Vue Component
View DateInput.vue
<label v-if="label" class="form-label" :for="`date-input-${_uid}`">{{ label }}:</label>
<input v-bind="$attrs" class="form-input" :id="`date-input-${_uid}`" :class="{ error: error }" type="text" ref="input" :value="value" @change="change" @keyup="change">
<div v-if="error" class="form-error">{{ error }}</div>
import pikaday from 'pikaday'
View order_by_nulls.php
use Illuminate\Database\Query\Builder;
Builder::macro('orderByNulls', function ($column, $direction = 'asc', $nulls = 'last', $bindings = []) {
$column = $this->getGrammar()->wrap($column);
$direction = strtolower($direction) === 'asc' ? 'asc' : 'desc';
$nulls = strtolower($nulls) === 'first' ? 'NULLS FIRST' : 'NULLS LAST';
return $this->orderByRaw("$column $direction $nulls", $bindings);