Skip to content

Commit fdc42f3

Browse files
author
Cristiano Lima
committed
Versão inicial do padrão digital de governo adaptado para Laravel
1 parent 05a4100 commit fdc42f3

File tree

148 files changed

+15447
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+15447
-0
lines changed

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
16+
17+
[docker-compose.yml]
18+
indent_size = 4

.env.example

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
APP_TIMEZONE=UTC
6+
APP_URL=http://localhost
7+
8+
APP_LOCALE=pt_BR
9+
APP_FALLBACK_LOCALE=en
10+
APP_FAKER_LOCALE=en_US
11+
12+
APP_MAINTENANCE_DRIVER=file
13+
# APP_MAINTENANCE_STORE=database
14+
15+
BCRYPT_ROUNDS=12
16+
17+
LOG_CHANNEL=stack
18+
LOG_STACK=single
19+
LOG_DEPRECATIONS_CHANNEL=null
20+
LOG_LEVEL=debug
21+
22+
DB_CONNECTION=sqlite
23+
# DB_HOST=127.0.0.1
24+
# DB_PORT=3306
25+
# DB_DATABASE=laravel
26+
# DB_USERNAME=root
27+
# DB_PASSWORD=
28+
29+
SESSION_DRIVER=database
30+
SESSION_LIFETIME=120
31+
SESSION_ENCRYPT=false
32+
SESSION_PATH=/
33+
SESSION_DOMAIN=null
34+
35+
BROADCAST_CONNECTION=log
36+
FILESYSTEM_DISK=local
37+
QUEUE_CONNECTION=database
38+
39+
CACHE_STORE=database
40+
CACHE_PREFIX=
41+
42+
MEMCACHED_HOST=127.0.0.1
43+
44+
REDIS_CLIENT=phpredis
45+
REDIS_HOST=127.0.0.1
46+
REDIS_PASSWORD=null
47+
REDIS_PORT=6379
48+
49+
MAIL_MAILER=log
50+
MAIL_HOST=127.0.0.1
51+
MAIL_PORT=2525
52+
MAIL_USERNAME=null
53+
MAIL_PASSWORD=null
54+
MAIL_ENCRYPTION=null
55+
MAIL_FROM_ADDRESS="hello@example.com"
56+
MAIL_FROM_NAME="${APP_NAME}"
57+
58+
AWS_ACCESS_KEY_ID=
59+
AWS_SECRET_ACCESS_KEY=
60+
AWS_DEFAULT_REGION=us-east-1
61+
AWS_BUCKET=
62+
AWS_USE_PATH_STYLE_ENDPOINT=false
63+
64+
VITE_APP_NAME="${APP_NAME}"

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
* text=auto eol=lf
2+
3+
*.blade.php diff=html
4+
*.css diff=css
5+
*.html diff=html
6+
*.md diff=markdown
7+
*.php diff=php
8+
9+
/.github export-ignore
10+
CHANGELOG.md export-ignore
11+
.styleci.yml export-ignore

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/.phpunit.cache
2+
/node_modules
3+
/public/build
4+
/public/hot
5+
/public/storage
6+
/storage/*.key
7+
/vendor
8+
.env
9+
.env.backup
10+
.env.production
11+
.phpactor.json
12+
.phpunit.result.cache
13+
Homestead.json
14+
Homestead.yaml
15+
auth.json
16+
npm-debug.log
17+
yarn-error.log
18+
/.fleet
19+
/.idea
20+
/.vscode
21+
.DS_Store

README.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Padrão Digital de Governo em Laravel
2+
3+
Template CSS do [Padrão Digital de Governo](https://www.gov.br/ds/ 'Acesse a página do Padrão Digital de Governo')
4+
adaptado para utilização no [Laravel](https://laravel.com/). A partir desse projeto é possível desenvolver uma aplicação
5+
PHP com a interface oficial do governo sem nenhuma configuração adicional de CSS. As classes utilizadas devem ser as
6+
mesmas presentes na [documentação oficial](https://www.gov.br/ds/home).
7+
8+
O [Padrão Digital de Governo](https://www.gov.br/ds/ 'Acesse a página do Padrão Digital de Governo') apresenta os
9+
padrões de interface que devem ser seguidos por designers e desenvolvedores para garantir a experiência única na
10+
interação dos usuários com os sistemas interativos do Governo Brasileiro.
11+
12+
## Estrutura de código
13+
14+
![Laravel](https://img.shields.io/badge/Laravel%2011-FF2D20?style=for-the-badge&logo=laravel&logoColor=white "Laravel 11")
15+
![Alpine JS](https://img.shields.io/badge/Alpine%20JS-8BC0D0?style=for-the-badge&logo=alpinedotjs&logoColor=black "Alpine JS")
16+
![GOV.BR](https://img.shields.io/badge/GOV.BR-blue?style=for-the-badge&labelColor=%23333&color=%230C326F&link=https%3A%2F%2Fwww.gov.br%2Fds)<img src="https://kapowaz.github.io/square-flags/flags/br.svg" height="28" width="30"/>
17+
![Biblioteca de componentes compatível com a versão 3.5.2 do ds](https://img.shields.io/badge/vers%C3%A3o%203.5.2%20do%20ds-blue?style=for-the-badge&labelColor=%23333&color=%230C326F&link=https%3A%2F%2Fwww.gov.br%2Fds)
18+
19+
- O ambiente BASE foi configurado com [LARAVEL SAIL](https://laravel.com/docs/11.x/sail) + [LARAVEL BREEZE](https://laravel.com/docs/11.x/starter-kits#laravel-breeze).
20+
- O CSS utilizado é o do padrão oficial do governo. Para mais detalhes, acesse a [documentação oficial](https://www.gov.br/ds/home).
21+
- De forma complementar, foi instalado o [laravel-pt-BR-localization](https://github.com/lucascudo/laravel-pt-BR-localization), que implementa a tradução do Laravel para PT-BR.
22+
23+
## Capturas de tela
24+
25+
### Login (Laravel Breeze)
26+
<kbd>![Tela de Login]( screenshots/1.png )</kbd>
27+
28+
---
29+
30+
### Registro de usuário (Laravel Breeze)
31+
<kbd>![Tela de ](screenshots/2.png)</kbd>
32+
---
33+
34+
### Painel inicial
35+
<kbd>![Tela de ](screenshots/3.png)</kbd>
36+
37+
---
38+
39+
### Template base
40+
<kbd>![Tela de ](screenshots/4.png)</kbd>
41+
42+
---
43+
44+
### Menu lateral
45+
<kbd>![Tela de ](screenshots/5.png)</kbd>
46+
47+
---
48+
49+
### Perfil de usuário (Laravel Breeze)
50+
<kbd>![Tela de ](screenshots/6.png)</kbd>
51+
52+
---
53+
54+
## Instalação e primeiro acesso
55+
56+
### Comandos essenciais para rodar
57+
58+
##### 1 - Cria um alias para execurar o [Laravel Sail](https://laravel.com/docs/sail) de forma facilitada:
59+
```bash
60+
alias sail='sh $([ -f sail ] && echo sail || echo vendor/bin/sail)'
61+
```
62+
63+
##### 2 - Instala dependências para execurar o [Laravel Sail](https://laravel.com/docs/sail):
64+
```bash
65+
docker run --rm \
66+
-u "$(id -u):$(id -g)" \
67+
-v "$(pwd):/var/www/html" \
68+
-w /var/www/html \
69+
laravelsail/php82-composer:latest \
70+
composer install --ignore-platform-reqs
71+
```
72+
73+
##### 3 - Instala dependências NPM:
74+
```bash
75+
npm install
76+
```
77+
78+
##### 4 - Cria o arquivo '.env' a partir do arquivo exemplo:
79+
```bash
80+
cp .env.example .env
81+
```
82+
##### 5 - Após criar o arquivo '.env', é necessário configurar as variáveis `FORWARD_DB_PORT`, `DB_CONNECTION`, `DB_HOST`, `DB_PORT`, `DB_DATABASE`,`DB_USERNAME`, `DB_PASSWORD`. Sem essa configuração, o sistema não consegue se comunicar com o banco de dados.
83+
84+
Exemplo de configuração:
85+
```php
86+
FORWARD_DB_PORT=6543
87+
DB_CONNECTION=pgsql
88+
DB_HOST=pgsql
89+
DB_PORT=5432
90+
DB_DATABASE=teste
91+
DB_USERNAME=teste
92+
DB_PASSWORD=123456
93+
```
94+
##### 6 - Ainda no arquivo '.env', é necessário criar a variável `APP_PORT` e atribuir a ela o número da porta desejada para acesso do sistema no navegador.
95+
96+
##### 6.1 - Exemplo de configuração:
97+
```php
98+
APP_PORT=123
99+
APP_URL=http://localhost:${APP_PORT}
100+
```
101+
102+
No exemplo de configuração acima, o sistema estará disponível na seguinte URL:
103+
```php
104+
http://localhost:123
105+
```
106+
##### 7 - Configura a `APP_KEY` do sistema. Por que isso é necessário? Mais detalhes [aqui](https://laravel.com/docs/encryption).
107+
108+
```bash
109+
php artisan key:generate
110+
```
111+
112+
##### 8 - Roda os serviços via [Laravel Sail](https://laravel.com/docs/sail), em modo "detached":
113+
```bash
114+
sail up -d
115+
```
116+
##### 9 - Roda todas as migrations do sistema para o Laravel Breeze funcionar. Por que isso é necessário? Mais detalhes [aqui](https://laravel.com/docs/migrations).
117+
```bash
118+
sail artisan migrate
119+
```
120+
121+
##### 10 - Compila o CSS:
122+
```bash
123+
sail npm run build
124+
```
125+
126+
##### 11 - Primeiro acesso
127+
128+
No primeiro acesso é necessário cadastrar um usuário. Caso tenha configurado a variável a `APP_PORT` [conforme o exemplo indicado](#61---exemplo-de-configuração), é possível fazer o procedimento pelo link:
129+
130+
```php
131+
http://localhost:123/register
132+
```
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\Http\Controllers\Controller;
6+
use App\Http\Requests\Auth\LoginRequest;
7+
use Illuminate\Http\RedirectResponse;
8+
use Illuminate\Http\Request;
9+
use Illuminate\Support\Facades\Auth;
10+
use Illuminate\View\View;
11+
12+
class AuthenticatedSessionController extends Controller
13+
{
14+
/**
15+
* Display the login view.
16+
*/
17+
public function create(): View
18+
{
19+
return view('auth.login');
20+
}
21+
22+
/**
23+
* Handle an incoming authentication request.
24+
*/
25+
public function store(LoginRequest $request): RedirectResponse
26+
{
27+
$request->authenticate();
28+
29+
$request->session()->regenerate();
30+
31+
return redirect()->intended(route('dashboard', absolute: false));
32+
}
33+
34+
/**
35+
* Destroy an authenticated session.
36+
*/
37+
public function destroy(Request $request): RedirectResponse
38+
{
39+
Auth::guard('web')->logout();
40+
41+
$request->session()->invalidate();
42+
43+
$request->session()->regenerateToken();
44+
45+
return redirect('/');
46+
}
47+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\Http\Controllers\Controller;
6+
use Illuminate\Http\RedirectResponse;
7+
use Illuminate\Http\Request;
8+
use Illuminate\Support\Facades\Auth;
9+
use Illuminate\Validation\ValidationException;
10+
use Illuminate\View\View;
11+
12+
class ConfirmablePasswordController extends Controller
13+
{
14+
/**
15+
* Show the confirm password view.
16+
*/
17+
public function show(): View
18+
{
19+
return view('auth.confirm-password');
20+
}
21+
22+
/**
23+
* Confirm the user's password.
24+
*/
25+
public function store(Request $request): RedirectResponse
26+
{
27+
if (! Auth::guard('web')->validate([
28+
'email' => $request->user()->email,
29+
'password' => $request->password,
30+
])) {
31+
throw ValidationException::withMessages([
32+
'password' => __('auth.password'),
33+
]);
34+
}
35+
36+
$request->session()->put('auth.password_confirmed_at', time());
37+
38+
return redirect()->intended(route('dashboard', absolute: false));
39+
}
40+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\Http\Controllers\Controller;
6+
use Illuminate\Http\RedirectResponse;
7+
use Illuminate\Http\Request;
8+
9+
class EmailVerificationNotificationController extends Controller
10+
{
11+
/**
12+
* Send a new email verification notification.
13+
*/
14+
public function store(Request $request): RedirectResponse
15+
{
16+
if ($request->user()->hasVerifiedEmail()) {
17+
return redirect()->intended(route('dashboard', absolute: false));
18+
}
19+
20+
$request->user()->sendEmailVerificationNotification();
21+
22+
return back()->with('status', 'verification-link-sent');
23+
}
24+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\Http\Controllers\Controller;
6+
use Illuminate\Http\RedirectResponse;
7+
use Illuminate\Http\Request;
8+
use Illuminate\View\View;
9+
10+
class EmailVerificationPromptController extends Controller
11+
{
12+
/**
13+
* Display the email verification prompt.
14+
*/
15+
public function __invoke(Request $request): RedirectResponse|View
16+
{
17+
return $request->user()->hasVerifiedEmail()
18+
? redirect()->intended(route('dashboard', absolute: false))
19+
: view('auth.verify-email');
20+
}
21+
}

0 commit comments

Comments
 (0)