Skip to content

Instantly share code, notes, and snippets.

View sjardim's full-sized avatar
🏠
Working from home

Sérgio Jardim sjardim

🏠
Working from home
View GitHub Profile
@sjardim
sjardim / UserResource.php
Last active March 20, 2024 07:25
Filament model with dependant selects
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\UsersResource\Pages;
use App\Filament\Resources\UsersResource\RelationManagers;
use App\Models\Company;
use App\Models\Folder;
use App\Models\User;
use App\Models\Users;
@sjardim
sjardim / Money.php
Last active November 4, 2023 21:21
Creating a Money custom field for Laravel Filament
<?php
declare(strict_types=1);
namespace App\Forms\Components;
use Filament\Forms\Components\Concerns\HasAffixes;
use Filament\Forms\Components\Field;
class Money extends Field
@sjardim
sjardim / processire-sync-s3-images.module.php
Last active August 11, 2023 04:20
'Synchronize all the page images uploaded through ProcessWire to a specified bucket in Amazon S3 and other places using Flysystem library.
<?php namespace ProcessWire;
use Aws\S3\S3Client;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local;
class ProcessSync extends WireData implements Module, ConfigurableModule {
public static function getModuleInfo() {
@sjardim
sjardim / simulated-typing.html
Created June 27, 2023 18:33 — forked from fontanon/simulated-typing.html
Simulate typing on HTML Input Box with Javascript
<html>
<head>
<title>Simulated typing</title>
</head>
<body>
<input type="text" id="transcribe-searchbox" placeholder="Escribe Aquí">
<input type="button" id="transcribe-button" value="Transcibir a Andaluz">
</body>
<script>
// Quotes to simulate typing, then deletion
@sjardim
sjardim / filament_table_aggregates.php
Created April 19, 2023 20:17
Adds a sum, avg, count column to a Laravel Filament table
//Adapted from https://filamentphp.com/tricks/aggregate-data-in-table-footer
// On your Resource list page
protected function getTableContentFooter(): View
{
return view('tables.footer', [
'calc_columns' => [
[
'column' => 'monthly_fee_in_cents',
'operation' => 'sum',
@sjardim
sjardim / NavigationComposer.php
Last active March 14, 2023 15:34
A flexible front end navigation build using the Filament admin for Laravel
<?php
namespace App\View\Composers;
use Illuminate\View\View;
use RyanChandler\FilamentNavigation\Facades\FilamentNavigation;
class NavigationComposer
{
# Salvar num arquivo ~/encode.sh, conceder direito de execução e
# executar desta forma (adaptar nomes de diretórios e arquivos para seu caso):
# $ ~/encode.sh ~/Video/bigFile.mp4 ~/Video/smallFile.mp4
ffmpeg -i "$1" -vcodec h264 -acodec aac "$2"
@sjardim
sjardim / index.php
Created February 8, 2023 12:53
Laravel Meilisearch search with relationships
<?php
//https://serversideup.net/advanced-meilisearch-queries-with-laravel-scout/
$customers = Customer::search('Dan')
->query( function( $query ){
$query->with('invoices');
} )->get();
@sjardim
sjardim / twill-light-and-dark-mode.css
Last active December 20, 2022 23:57
Light and Dark mode styles for Twill (twill.io) CMS admin
:root {
--primary-color-hue: 230;
--background-darkest: hsl(var(--primary-color-hue), 70%, 30%);
--background-darker: hsl(var(--primary-color-hue), 20%, 95%);
--background-normal: hsl(var(--primary-color-hue), 70%, 98%);
--background-contrast: hsl(var(--primary-color-hue), 90%, 100%);
--background-highlight: hsl(var(--primary-color-hue), 100%, 98%);
--border-normal: hsl(var(--primary-color-hue), 30%, 90%);
--border-highlight: hsl(var(--primary-color-hue), 100%, 95%);
--body-text-normal: hsl(var(--primary-color-hue), 45%, 55%);
<?php
namespace App\Filament\Resources\ItemResource\Pages;
use App\Filament\Resources\ItemResource;
use Filament\Resources\Pages\ListRecords;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\DB;
class CustomItemsList extends ListRecords