Skip to content

Instantly share code, notes, and snippets.

View Gummibeer's full-sized avatar
🐼
beary busy

Tom Herrmann Gummibeer

🐼
beary busy
View GitHub Profile
@Gummibeer
Gummibeer / app__Http__Middleware__Localized.php
Created October 8, 2019 15:16
set all locales if app locale changes
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
class Localized
{
@Gummibeer
Gummibeer / Car.php
Last active January 8, 2020 11:07
Car-User-Role permission scratch
<?php
class Car extends Model
{
public function users()
{
return $this->belongsToMany(User::class, 'car_user_role')
->using(CarUserRole::class)
->withPivot('role_id', 'user_id', 'car_id');
}
@Gummibeer
Gummibeer / TestCase.php
Last active March 21, 2020 14:37
phpunit testcase auto setup/teardown traits
<?php
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use JMac\Testing\Traits\HttpTestAssertions;
use Tests\Utils\CreateUploadedFileFromFilePath;
use Tests\Utils\IsRoutesAware;
use Tests\Utils\ResourceAsserts;
<?php /** @var Illuminate\View\ComponentAttributeBag $attributes */ ?>
<?php /** @var Illuminate\Support\HtmlString $slot */ ?>
<?php /** @var int $delay */ ?>
<?php /** @var string $callback */ ?>
<div x-data="abortableButton()" x-init="delay = {{ $delay ?? 5000 }}; callback = () => { {{ $callback }} };" class="w-1/2">
<template x-if="!clicked">
<button
type="button"
class="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded w-full"
@Gummibeer
Gummibeer / SignInController.php
Last active September 2, 2020 03:57
Laravel ThrottlesRequests trait
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Concerns\ThrottlesRequests;
use App\Http\Requests\Auth\SignInRequest;
use App\Http\Requests\Auth\SignUpRequest;
use App\Models\User;
use Illuminate\Auth\Events\Registered;
use Illuminate\Http\RedirectResponse;
class IpAddress
{
public string $ip;
public function __construct(string $ip)
{
$this->ip = $ip;
}
public function __toString(): string
# clear system caches
sudo rm -rf /Library/Caches/*
sudo rm -rf /System/Library/Caches/*
sudo rm -rf ~/Library/Caches/*
# clear dns cache
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
# clear google chrome cache
import {registerRoute} from 'workbox-routing';
import {StaleWhileRevalidate} from 'workbox-strategies';
import {CacheableResponsePlugin} from 'workbox-cacheable-response';
import {CacheFirst} from 'workbox-strategies';
import {ExpirationPlugin} from 'workbox-expiration';
self.addEventListener("message", (event) => {
if (event.data && event.data.type === "SKIP_WAITING") {
self.skipWaiting();
}
<?php
namespace App\Eloquent\Concerns;
use Illuminate\Database\Eloquent\Model as IlluminateModel;
use Illuminate\Support\Arr;
use Vinkla\Hashids\Facades\Hashids;
trait HasHashId
{
<?php
namespace JustSteveKing\Transporter;
use Illuminate\Http\Client\PendingRequest;
class CreateTodoRequest extends Request
{
protected string $method = 'POST';
protected string $baseUrl = 'https://jsonplaceholder.typicode.com';