Skip to content

Instantly share code, notes, and snippets.

View joaorobertopb's full-sized avatar
💻
Coding

João Roberto P. Borges joaorobertopb

💻
Coding
View GitHub Profile
<?php
/**
* Render an exception using Whoops.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
protected function renderExceptionWithWhoops($request, Exception $e)
@joaorobertopb
joaorobertopb / public-function-render.php
Last active February 14, 2017 01:01
Vamos repassar as exceptions para o Whoops somente quando o ambiente for local e se o debug estiver ativo.
<?php
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
@joaorobertopb
joaorobertopb / Handler.php
Created February 14, 2017 00:41
Registrando o package Filp/Whoops no Laravel
<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
@joaorobertopb
joaorobertopb / .php_cs.dist
Last active December 17, 2022 15:37
Esse é um exemplo de configuração do php-cs-fixer que foi construído usando a predefinição Laravel do StyleCI.
<?php
$header = <<<'EOF'
Esse arquivo faz parte de <Empresa/Projeto>
(c) Nome Autor <e-mail>
Lorem ipsum ...
EOF;
<?php
namespace App\Scope;
use Illumiante\Database\Query\Builder as QueryBuilder;
use Illuminate\Database\Eloquent\Builder;
use illuminate\Database\Eloquent\ScopeInterface;
class MultiEmpresaScope implements ScopeInterface {
<?php
namespace App\Scope;
trait IsMultiEmpresaTrait {
protected static function bootIsMultiEmpresa() {
static::addGlobalScope( new MultiEmpresaScope );
}
@joaorobertopb
joaorobertopb / php_cs.dist
Created April 28, 2018 19:07
Tutorial PHP CS Fixer
<?php
$finder = PhpCsFixer\Finder::create()
->exclude('somedir')
->notPath('src/Symfony/Component/Translation/Tests/fixtures/resources.php')
->in(__DIR__);
return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
@joaorobertopb
joaorobertopb / trecho-illuminate-model.php
Last active May 5, 2018 20:18
Exemplo de código utilizado em um dos meus artigos: medium.com/@joaorobertopb
<?php
//Trecho de código, retirado de https://github.com/laravel/framework/blob/5.6/src/Illuminate/Database/Eloquent/Model.php#L189
/**
* The "booting" method of the model.
*
* @return void
*/
protected static function boot()
@joaorobertopb
joaorobertopb / install-docker-ce-ubuntu-18.04.md
Last active December 18, 2018 16:16
Install docker on Ubuntu 18.04

Install docker - Ubuntu 18.04

sudo apt update

sudo apt install apt-transport-https ca-certificates curl software-properties-common

sudo gedit /etc/apt/sources.list.d/docker.list

copy this line: deb [arch=amd64] https://download.docker.com/linux/ubuntu artful stable save file!