Skip to content

Instantly share code, notes, and snippets.

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

Mauricio Rodrigues zabaala

🏠
Working from home
View GitHub Profile
@zabaala
zabaala / FormBuilder.php
Created April 12, 2016 17:42
Extends Illuminate\Html\FormBuilder
<?php
namespace M2Digital\Extras\Html;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Html\FormBuilder as IlluminateFormBuilder;
class FormBuilder extends IlluminateFormBuilder {
function slugify(str) {
str = str.toString().toLowerCase().trim()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/&/g, '-and-') // Replace & with 'and'
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-'); // Replace multiple - with single -
return str;
}
DROP IF EXISTS TABLE [tmp_table_name];
CREATE TABLE [tmp_table_name] engine=innodb (select * from [reference_table] where ...);
SELECT
TABLE_NAME AS `Table`,
ROUND(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM
INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '[schema]' AND TABLE_NAME = '[tmp_table_name]';
@zabaala
zabaala / DescTableCommand.php
Last active June 18, 2018 23:36
A desc table command for artisans
<?php
namespace App\Commands;
use Illuminate\Console\Command;
class DescTableCommand extends Command
{
/**
* The name and signature of the console command.
@zabaala
zabaala / eg.php
Created September 12, 2017 14:08
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
class AplicacaoController extends Controller
{
private $session;
@zabaala
zabaala / TokenMismatchException.php
Last active October 19, 2017 13:59
Override Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php class
<?php
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*
*/
public function handle($request, Closure $next)
@zabaala
zabaala / BindDatabaseServiceProvider.php
Last active March 2, 2021 07:50
php artisan db:log <start> <stop>
<?php
namespace App\Commands\Database;
use Illuminate\Support\ServiceProvider;
class BindDatabaseServiceProvider extends ServiceProvider
{
public function boot()
{
input {
file {
path => "/data/logs/laravel/laravel.log"
start_position => "beginning"
type => "laravel_core_log"
codec => multiline {
pattern => "^\["
what => "previous"
negate => true
}
<?php
# Ex 2
use App\Applications\Backend\Http\Controllers\ExampleController;
Route::get('/{locale}/hackaton', function (\Illuminate\Http\Request $request) {
App::setLocale($request->locale);
return app(ExampleController::class)->callAction('index', []);
});
<?php
namespace App;
class CacheProductRepository extends ProductInterface
{
public function getAll()
{
// Get all products from redis...
}