Skip to content

Instantly share code, notes, and snippets.

View PierreLebedel's full-sized avatar

Pierre Lebedel PierreLebedel

View GitHub Profile
@PierreLebedel
PierreLebedel / toast-message.blade.php
Last active October 3, 2024 09:35
TallStackUI component to show toast message on Livewire event (to replace Jetstream action-message component for example)
@props(['on', 'method'=>'success', 'title'=>null])
@php
if( !in_array($method, ['success', 'warning', 'error', 'info']) ){
$method = 'info';
}
if( empty($title) && $slot->isEmpty() ){
$title = __('Success');
}
@endphp
@PierreLebedel
PierreLebedel / AppServiceProvider
Last active October 14, 2024 12:50
Pluck Laravel collection by unique field (Typically User's First Name)
public function boot(): void
{
Collection::macro('pluckUnique', function (string $firstAttribute, string $secondAttribute, $glue = null) {
return $this->map(function ($item) use ($firstAttribute, $secondAttribute) {
$item->firstAttributeCleaned = Str::lower($item->{$firstAttribute});
$item->secondattributeCleaned = Str::lower($item->{$secondAttribute});
return $item;
})->mapWithKeys(function ($value, $key) use ($firstAttribute, $secondAttribute, $glue) {
@PierreLebedel
PierreLebedel / app.js
Created January 10, 2025 11:25
Phone input with intlTelInput + Livewire + Alpine
import intlTelInput from 'intl-tel-input';
import { fr } from "intl-tel-input/i18n";
window.setupPhoneInput = function (element, options) {
return intlTelInput(element, {...{
loadUtils: () => import("intl-tel-input/utils"),
i18n: fr,
nationalMode: false
}, ...options});
}
@PierreLebedel
PierreLebedel / .env
Last active March 28, 2025 19:54
Laravel 12 Meilisearch command for "composer run dev"
MEILISEARCH_HOST=http://127.0.0.1:7700
MEILISEARCH_KEY=masterKey
MEILISEARCH_BIN="C:\\path\\to\\meilisearch\\bin" # Add this