Skip to content

Instantly share code, notes, and snippets.

@pedroufv
pedroufv / Inflector.php
Created February 8, 2021 23:29
Pluralize pt-br
<?php
namespace Laravel\Support\Services;
class Inflector
{
/**
* @var array
*/
public static $rules = [
@pedroufv
pedroufv / logger sql to laravel
Created November 30, 2018 19:45
show all sql add this code in boot method of appServiceProvider
DB::listen(function(QueryExecuted $query){
Logger(
vsprintf(str_replace('?', '%s', $query->sql), collect($query->bindings)->map(function($binding){
return is_numeric($binding) ? $binding : "'{$binding}'";
})->toArray())
);
});
@pedroufv
pedroufv / PermissionsTableSeeder.php
Created January 30, 2018 16:21
Poupula tabela de permissões
<?php
use Illuminate\Database\Seeder;
class PermissionsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
@pedroufv
pedroufv / AdminController.php
Last active January 30, 2018 16:14
AdminiController verificando permissão larapacks/authorization
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Route;
class AdminController extends Controller
{
public function __construct()
@pedroufv
pedroufv / titleCase.php
Created January 26, 2018 13:16
ignora algumas palavras pro ucfirst como ['de', 'do', 'da', 'e'...]
<?php
function titleCase($str, $ignored = []) {
$words = explode(' ', $str);
foreach ($words as &$word) {
if (in_array($word, $ignored) {
continue;
}