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 / 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 / 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 / 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();
<?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
@sjardim
sjardim / update_meilisearch_index_command.php
Created May 31, 2022 18:10
Laravel command to update Meilisearch's index and filterable attributes
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use MeiliSearch\Client;
use function PHPUnit\Framework\throwException;
class UpdateMeilisearchIndex extends Command
{
@sjardim
sjardim / twill-nested-module-urls.md
Created February 1, 2022 15:25 — forked from chrispymm/twill-nested-module-urls.md
[Support nested urls for nested modules] #twill

By default Twill will disply the url of a module item to be {siteurl}/{module}/{slug} e.g. mysite.com/pages/about. With the 'about' section being the editable slug. This is understandable as Twill knows nothing of your frontend routing. However it is likely confusing for editors, as that url presented will not be the final url of the content.

Remove module name form url

This will give us more correct urls e.g. mysite.com/about

// app/Http/Controllers/Admin/PageController

	protected $permalinkBase = '';