Skip to content

Instantly share code, notes, and snippets.

@tanthammar
tanthammar / AutoGeneratesPosition.php
Last active February 20, 2021 04:17
Auto generate spatial point when creating or updating a Model
<?php
namespace App\Traits;
use App\Helpers\GeoHelper;
use Grimzy\LaravelMysqlSpatial\Types\Point;
trait AutoGeneratesPosition
{
@tanthammar
tanthammar / always-on-top.js
Created May 14, 2021 17:31
JS Get highest z-index, always on top
window.findHighestZ = () => [...document.querySelectorAll('body *')]
.map(elt => parseFloat(getComputedStyle(elt).zIndex))
.reduce((z, highest=Number.MIN_SAFE_INTEGER) =>
isNaN(z) || z < highest ? (isNaN(highest) ? 1 : highest) : z
)
//vanilla
document.getElementById("foo").style.zIndex = window.findHighestZ()
If you're into
- Laravel, https://laravel.com/
- Filament https://filamentphp.com/
- DTOs or Json columns.
Some templates...
@tanthammar
tanthammar / AppServiceProvider.php
Created March 16, 2023 18:10 — forked from paulund/AppServiceProvider.php
Laravel Cache Auth::user(). Learn how to cache the logged in user at https://paulund.co.uk/laravel-cache-authuser
<?php
namespace App\Providers;
use App\Models\User;
use App\Observers\UserObserver;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{