Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions test-backend/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
44 changes: 44 additions & 0 deletions test-backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
5 changes: 5 additions & 0 deletions test-backend/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
12 changes: 12 additions & 0 deletions test-backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
13 changes: 13 additions & 0 deletions test-backend/.styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
php:
preset: laravel
disabled:
- unused_use
finder:
not-name:
- index.php
- server.php
js:
finder:
not-name:
- webpack.mix.js
css: true
42 changes: 42 additions & 0 deletions test-backend/app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];

/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
}

/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');

require base_path('routes/console.php');
}
}
51 changes: 51 additions & 0 deletions test-backend/app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace App\Exceptions;

use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];

/**
* Report or log an exception.
*
* @param \Exception $exception
* @return void
*/
public function report(Exception $exception)
{
parent::report($exception);
}

/**
* 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)
{
return parent::render($request, $exception);
}
}
113 changes: 113 additions & 0 deletions test-backend/app/Helpers/ValidateDocuments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php

namespace App\Helpers;

class ValidateDocuments
{
public function validaCPF($cpf)
{
// Extrai somente os números
$cpf = preg_replace('/[^0-9]/is', '', $cpf);

// Verifica se foi informado todos os digitos corretamente
if (strlen($cpf) != 11) {
return false;
}

// Verifica se foi informada uma sequência de digitos repetidos. Ex: 111.111.111-11
if (preg_match('/(\d)\1{10}/', $cpf)) {
return false;
}

// Faz o calculo para validar o CPF
for ($t = 9; $t < 11; $t++) {
for ($d = 0, $c = 0; $c < $t; $c++) {
$d += $cpf[$c] * (($t + 1) - $c);
}
$d = ((10 * $d) % 11) % 10;
if ($cpf[$c] != $d) {
return false;
}
}
return true;
}

public function validaCNPJ($cnpj)
{
// Deixa o CNPJ com apenas números
$cnpj = preg_replace('/[^0-9]/', '', $cnpj);

// Garante que o CNPJ é uma string
$cnpj = (string)$cnpj;

// O valor original
$cnpj_original = $cnpj;

// Captura os primeiros 12 números do CNPJ
$primeiros_numeros_cnpj = substr($cnpj, 0, 12);

/**
* Multiplicação do CNPJ
*
* @param string $cnpj Os digitos do CNPJ
* @param int $posicoes A posição que vai iniciar a regressão
* @return int O
*
*/
if (!function_exists('multiplica_cnpj')) {
function multiplica_cnpj($cnpj, $posicao = 5)
{
// Variável para o cálculo
$calculo = 0;

// Laço para percorrer os item do cnpj
for ($i = 0; $i < strlen($cnpj); $i++) {
// Cálculo mais posição do CNPJ * a posição
$calculo = $calculo + ($cnpj[$i] * $posicao);

// Decrementa a posição a cada volta do laço
$posicao--;

// Se a posição for menor que 2, ela se torna 9
if ($posicao < 2) {
$posicao = 9;
}
}
// Retorna o cálculo
return $calculo;
}
}

// Faz o primeiro cálculo
$primeiro_calculo = multiplica_cnpj($primeiros_numeros_cnpj);

// Se o resto da divisão entre o primeiro cálculo e 11 for menor que 2, o primeiro
// Dígito é zero (0), caso contrário é 11 - o resto da divisão entre o cálculo e 11
$primeiro_digito = ($primeiro_calculo % 11) < 2 ? 0 : 11 - ($primeiro_calculo % 11);

// Concatena o primeiro dígito nos 12 primeiros números do CNPJ
// Agora temos 13 números aqui
$primeiros_numeros_cnpj .= $primeiro_digito;

// O segundo cálculo é a mesma coisa do primeiro, porém, começa na posição 6
$segundo_calculo = multiplica_cnpj($primeiros_numeros_cnpj, 6);
$segundo_digito = ($segundo_calculo % 11) < 2 ? 0 : 11 - ($segundo_calculo % 11);

// Concatena o segundo dígito ao CNPJ
$cnpj = $primeiros_numeros_cnpj . $segundo_digito;

// Verifica se o CNPJ gerado é idêntico ao enviado
if ($cnpj === $cnpj_original) {
return true;
}
}

public function Mask($mask, $str)
{
$str = str_replace(" ", "", $str);
for ($i = 0; $i < strlen($str); $i++) {
$mask[strpos($mask, "#")] = $str[$i];
}
return $mask;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;

class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/

use SendsPasswordResetEmails;

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}
39 changes: 39 additions & 0 deletions test-backend/app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/

use AuthenticatesUsers;

/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/home';

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
}
Loading