Skip to content

Instantly share code, notes, and snippets.

@nathandaly
nathandaly / BaseResource.php
Last active October 10, 2024 22:35
Tenancy for Laravel & Filament V3 (Tenant per database)
<?php
/**
* Below is an the extended Filament resource your tenant panel resources
* will have to extend so that the queries are scoped properly.
*/
namespace App\Filament;
use Filament\Resources\Resource;
@nathandaly
nathandaly / laravel_routine.go
Created June 8, 2023 18:02
ChatGPT: Using GoLang's coroutines to handle Laravel jobs
package main
import (
"fmt"
"log"
"sync"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
@nathandaly
nathandaly / modal.blade.php
Last active May 21, 2024 14:48
Alpine Bootstrap Modal
<div name="{{ $name }}"
x-cloak
x-data="{ show: false, name: '{{ $name }}', details: null }"
@modal.window="
show = ($event.detail.name === name);
details = $event.detail;
"
@modal:close-all.window="show = false"
class="modal d-block"
tabindex="-1"
@nathandaly
nathandaly / AgeCalculation.php
Last active November 27, 2020 10:23
Calculate Age in PHP
<?php
declare(strict_types=1);
namespace App;
use App\Models\Age;
use Carbon\Carbon;
class AgeCalculator
<div class="bg-red-500 p-1.5 responsive-debug text-center">
<div class="hidden sm:hidden md:hidden lg:hidden xl:visible xl:block">XL</div>
<div class="hidden sm:hidden md:hidden lg:visible lg:block xl:hidden">LG</div>
<div class="hidden sm:hidden md:visible md:block lg:hidden xl:hidden">MD</div>
<div class="hidden sm:visible sm:block md:hidden lg:hidden xl:hidden">SM</div>
<div class="sm:hidden md:hidden lg:hidden xl:hidden">&lt; SM</div>
</div>
@nathandaly
nathandaly / uk_postcode_validator.php
Created October 13, 2020 09:33 — forked from sepehr/uk_postcode_validator.php
PHP: UK Postcode Validation
/**
* Custom validation callback to validate UK postcodes.
*
* It also tries to format provided postcode in correct format.
*
* Note: It's only usable for "postcode" fields.
*/
public function check_postcode_uk($original_postcode)
{
// Set callback's custom error message (CI specific)
@nathandaly
nathandaly / example.php
Created February 25, 2020 10:42
Example CRUD
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class Example extends Controller
{
/**
* Display a listing of the resource.
<template>
<q-page ref="timeline" class="bg-grey-6 q-pt-xs">
<div class="q-mb-sm">
<q-banner v-show="postsCollection.length === 0 && !posts.loading && !newPost.loading" class="text-center text-pink-14 bg-white">
There are no posts yet, be the first.
</q-banner>
<Post v-if="newPost.loading" :ajaxLoader="newPost.loading" :post="newPost.payload"></Post>
<q-infinite-scroll @load="onLoad" :offset="500" ref="infiniteScroll">
<Post v-for="post in filterPostsByGroup" v-bind:key="post.id" :post="post"></Post>
<template v-slot:loading>
@nathandaly
nathandaly / actions.js
Last active November 26, 2019 19:58
Using a DB with Vuex.
export function createPerson ({ commit }, payload) {
const person = {
...payload,
type: 'member'
}
this._vm.$db.insert(person, (err, newDoc) => {
// NeDB: Callback is optional
// newDoc is the newly inserted document, including its _id
if (err) {
return err