Skip to content

Instantly share code, notes, and snippets.

@renatofrota
renatofrota / Remember.php
Created September 9, 2024 12:43
Remember: a simple Laravel / PHP volatile runtime cache
<?php
// save this file as ./app/Helpers/Remember.php
namespace App\Helpers {
class Remember
{
public static array $that = [];
}
@renatofrota
renatofrota / tutorial.php
Last active September 24, 2024 03:36
Seletor de idioma no Filament 3 com auto-detecção de idioma
<?php
// routes/web.php
Route::get('lang/{lang}', function ($lang) {
session()->put('current_lang', $lang);
return redirect(url()->previous());
});
// app/providers/Filament/AdminPanelProvider.php
@renatofrota
renatofrota / lib_adianti_database_TTransaction.php
Created July 24, 2024 03:19
Prevenir database deadlock ao usar banco de dados SQLite no Adianti / MadBuilder
<?php
namespace Adianti\Database;
use Adianti\Core\AdiantiCoreTranslator;
use Adianti\Database\TConnection;
use Adianti\Log\TLogger;
use Adianti\Log\TLoggerSTD;
use Adianti\Log\TLoggerTXT;
use Adianti\Log\AdiantiLoggerInterface;
@renatofrota
renatofrota / js.js
Created May 8, 2024 06:45
Adianti Framework SPA (Single Page Application)
Adianti.registerState = false;
if (typeof history.replaceState != 'undefined') {
var baseurl = window.location.pathname.replace(/index\.php.*/,'');
var stateObj = { url: baseurl };
history.replaceState(stateObj, '', baseurl);
}
@renatofrota
renatofrota / css.css
Created April 30, 2024 13:45
CSS de Base - Theme Builder (MadBuilder)
:root
{
--botao-primario-fundo: #1a3460 !important;
--botao-primario-borda: #1a3460;
--botao-primario-texto: #fff;
--botao-primario-fundo-foco: #1a3460 !important;
--botao-primario-borda-foco: #fd9203;
--botao-borda-foco: #fd9203;
--campo-fundo-foco: #ffdfb4;
--text-color: #333;
@renatofrota
renatofrota / init.php
Last active April 30, 2024 20:02
Adianti Debug - Funções d, dd, p, pp
<?php
// adicione estas funções no arquivo init.php
// uso: d($argumento1, $argumento2, ...);
// https://github.com/renatofrota
// dump
function d(...$args)
{
$bt = debug_backtrace();
@renatofrota
renatofrota / Navegacao.php
Last active December 15, 2023 20:20
Classe de Navegação para Adianti Framework
<?php
/**
* Classe de Navegação para Adianti Framework
*
* Guarda e recupera parametros relacionados (order, offset, limit, direction, page, first_page)
* para manter o estado da paginação dos datagrids ao navegar pelas classes e janelas do sistema
*
* @author Renato Frota <[email protected]>
*/
@renatofrota
renatofrota / functions.php
Created July 11, 2020 01:27 — forked from fernandoacosta/functions.php
Adicionar campo personalizado na busca de pedidos WooCommerce
<?php
/**
* @woo_custom_search
* @param string $search_fields
*/
function woo_custom_search( $search_fields ) {
$search_fields[] = 'Método de pagamento';
return $search_fields;
}
add_filter( 'woocommerce_shop_order_search_fields', 'woo_custom_search' );
@renatofrota
renatofrota / install.sh
Last active May 2, 2022 12:34
Deploy Chrome OS (Brunch Framework)
#!/bin/bash
# https://bit.ly/chrome-os-install-sh
# Script to deploy Chrome OS (using Brunch Framework)
# Author renatofrota: https://github.com/renatofrota/
# Brunch Framework: https://github.com/sebanc/brunch/
deployed() {
echo "Deployment complete. Install script by Renato Frota. Donate:"
echo "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=R58RLRMM8YM6U"
xdg-open "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=R58RLRMM8YM6U"
}
@renatofrota
renatofrota / toggle-search-form.php
Last active March 16, 2020 11:14
Adicionar botão para esconder/exibir formulário de busca (filtros) no Adianti Framework
<?php
class SuaPagina extends TPage
{
private $form; // form
private $datagrid; // listing
private $pageNavigation;
private $loaded;
private $filter_criteria;
private static $database = 'seubanco';