Skip to content

Instantly share code, notes, and snippets.

<?php
namespace App\Charts;
use App\Support\Livewire\ChartComponentData;
use ConsoleTVs\Charts\Classes\Chartjs\Chart;
/**
* Class WanSpeedTestsChart
*
@tanthammar
tanthammar / Media.blade.php
Last active October 19, 2022 00:01
LiveWire Spatie Media Image upload with VueCroppa
<div id="media-comp" class="display-contents">
<media inline-template>
<form>
<div v-for="(image, index) in form" :key="index" @touchstart.stop @mousedown.stop class="col-span-6">
<h3 class="text-3xl font-medium">@{{ image.label }}</h3>
<p class="py-3">Allowed Width @{{image.width}}px, Height @{{image.height}}px, Max file size @{{image.maxFileSize}}</p>
<input v-model="image.value" wire:model="@{{ image.name }}" type="hidden">
<croppa v-model="image.model" :width="image.width" :height="image.height"
:placeholder="locale == 'sv' ? 'Välj en bild' : 'Choose an image'"
:accept="'image/*'" :file-size-limit="image.maxByte" :zoom-speed="3" :disable-drag-and-drop="false"
@tanthammar
tanthammar / LivewireSortable.php
Last active August 9, 2022 20:52
Livewire Sortable fix with array form
<?php
namespace App\Http\Livewire\App\Organizers\Forms;
use App\Http\Livewire\Traits\Form;
use App\Models\Organizer;
use Livewire\Component;
class People extends Component
{
@tanthammar
tanthammar / trix.blade.php
Last active February 8, 2023 22:18
Livewire trix input
@push('body-styles')
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/trix/1.2.0/trix.css">
@endpush
<form x-data="form()">
<input x-ref="description" id="description" name="description" value='{{ $description }}' type="hidden" />
<div wire:ignore>
<trix-editor input="description"></trix-editor>
</div>
@tanthammar
tanthammar / capturePlainTextOnPaste.js
Created May 2, 2020 16:58
Capture plain-text on paste JS
/**
* Capture the <CTL-V> paste event, only allow plain-text, no images.
*
* see: https://stackoverflow.com/a/28213320
*
* @param {object} evt - array of files
* @author Daniel Thompson-Yvetot
* @license MIT
*/
pasteCapture(evt, ref) {
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddIndexToTranslatedNamesTable extends Migration
{
protected $tables = ['organizers', 'events', 'bookers',
'categories', 'terms', 'tabs', 'helps',
@tanthammar
tanthammar / HasLinks.php
Last active July 10, 2020 11:14
Laravel Append Model Links
@tanthammar
tanthammar / HasUuidTrait.php
Last active January 28, 2021 16:47
Laravel Model Uuid trait
<?php
namespace App\Traits;
use Hidehalo\Nanoid\Client;
/**
* Source: https://github.com/jamesmills/eloquent-uuid
* added prefix
* last updated 28 jan 2021.
@tanthammar
tanthammar / Response.php
Created February 13, 2020 10:48 — forked from jeffochoa/Response.php
Laravel HTTP status code
<?php
// This can be found in the Symfony\Component\HttpFoundation\Response class
const HTTP_CONTINUE = 100;
const HTTP_SWITCHING_PROTOCOLS = 101;
const HTTP_PROCESSING = 102; // RFC2518
const HTTP_OK = 200;
const HTTP_CREATED = 201;
const HTTP_ACCEPTED = 202;
@tanthammar
tanthammar / ocr.php
Created September 27, 2019 10:38 — forked from AdamGerthel/ocr.php
Generate BankGiro/PlusGiro OCR numbers via PHP
<?php
/**
* OCR Number generation function
*
* @param string $base_number
* The base number that you wish to use for the OCR nr. Can be any number,
* but usually consists of client ID combined with invoice ID or similar.
* @param boolean $length
* Use length if you want the OCR number to add a length