Skip to content

Commit 87b599a

Browse files
author
marcelosmbr
committed
first commit
0 parents  commit 87b599a

File tree

79 files changed

+10955
-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.

79 files changed

+10955
-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=en
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=mysql
23+
DB_HOST=db
24+
DB_PORT=3306
25+
DB_DATABASE=laravel
26+
DB_USERNAME=root
27+
DB_PASSWORD=root
28+
29+
SESSION_DRIVER=redis
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=redis
38+
39+
CACHE_STORE=redis
40+
CACHE_PREFIX=
41+
42+
MEMCACHED_HOST=127.0.0.1
43+
44+
REDIS_CLIENT=phpredis
45+
REDIS_HOST=redis
46+
REDIS_PASSWORD=null
47+
REDIS_PORT=6379
48+
49+
MAIL_MAILER=smtp
50+
MAIL_HOST=mailhog
51+
MAIL_PORT=125
52+
MAIL_USERNAME=null
53+
MAIL_PASSWORD=null
54+
MAIL_ENCRYPTION=tls
55+
MAIL_FROM_ADDRESS="[email protected]"
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+
/.docker

Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
FROM php:8.3-fpm
2+
3+
# set your user name, ex: user=carlos
4+
ARG user=yourusername
5+
ARG uid=1000
6+
7+
# Install system dependencies
8+
RUN apt-get update && apt-get install -y \
9+
git \
10+
curl \
11+
libpng-dev \
12+
libonig-dev \
13+
libxml2-dev \
14+
zip \
15+
unzip
16+
17+
# Clear cache
18+
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
19+
20+
# Install PHP extensions
21+
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd sockets
22+
23+
# Get latest Composer
24+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
25+
26+
# Create system user to run Composer and Artisan Commands
27+
RUN useradd -G www-data,root -u $uid -d /home/$user $user
28+
RUN mkdir -p /home/$user/.composer && \
29+
chown -R $user:$user /home/$user
30+
31+
# Install redis
32+
RUN pecl install -o -f redis \
33+
&& rm -rf /tmp/pear \
34+
&& docker-php-ext-enable redis
35+
36+
# Set working directory
37+
WORKDIR /var/www
38+
39+
# Copy custom configurations PHP
40+
COPY docker/php/custom.ini /usr/local/etc/php/conf.d/custom.ini
41+
42+
USER $user

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
2+
3+
<p align="center">
4+
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
5+
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
6+
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
7+
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
8+
</p>
9+
10+
## About Laravel
11+
12+
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
13+
14+
- [Simple, fast routing engine](https://laravel.com/docs/routing).
15+
- [Powerful dependency injection container](https://laravel.com/docs/container).
16+
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
17+
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
18+
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
19+
- [Robust background job processing](https://laravel.com/docs/queues).
20+
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
21+
22+
Laravel is accessible, powerful, and provides tools required for large, robust applications.
23+
24+
## Learning Laravel
25+
26+
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
27+
28+
You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
29+
30+
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
31+
32+
## Laravel Sponsors
33+
34+
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
35+
36+
### Premium Partners
37+
38+
- **[Vehikl](https://vehikl.com/)**
39+
- **[Tighten Co.](https://tighten.co)**
40+
- **[WebReinvent](https://webreinvent.com/)**
41+
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
42+
- **[64 Robots](https://64robots.com)**
43+
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
44+
- **[Cyber-Duck](https://cyber-duck.co.uk)**
45+
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
46+
- **[Jump24](https://jump24.co.uk)**
47+
- **[Redberry](https://redberry.international/laravel/)**
48+
- **[Active Logic](https://activelogic.com)**
49+
- **[byte5](https://byte5.de)**
50+
- **[OP.GG](https://op.gg)**
51+
52+
## Contributing
53+
54+
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
55+
56+
## Code of Conduct
57+
58+
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
59+
60+
## Security Vulnerabilities
61+
62+
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [[email protected]](mailto:[email protected]). All security vulnerabilities will be promptly addressed.
63+
64+
## License
65+
66+
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Api;
4+
5+
use App\Http\Controllers\Controller;
6+
use Illuminate\Support\Facades\Cache;
7+
use App\Models\User;
8+
use App\Http\Requests\User\StoreUserRequest;
9+
use App\Http\Requests\User\UpdateUserRequest;
10+
use App\Http\Resources\UserResource;
11+
use App\Jobs\NotifyNewUserJob;
12+
13+
class UserController extends Controller
14+
{
15+
function __construct(User $user)
16+
{
17+
$this->model = $user;
18+
}
19+
20+
public function indexCache()
21+
{
22+
$users = Cache::rememberForever('users', function () {
23+
return $this->model->all();
24+
});
25+
26+
return UserResource::collection($users);
27+
}
28+
29+
public function indexNoCache()
30+
{
31+
$users = $this->model->all();
32+
33+
return UserResource::collection($users);
34+
}
35+
36+
public function store(StoreUserRequest $request)
37+
{
38+
$user = $this->model->create($request->validated());
39+
40+
Cache::forget('users');
41+
42+
NotifyNewUserJob::dispatch($user)->onQueue('default');
43+
44+
return new UserResource($user);
45+
}
46+
47+
public function show(string $public_id)
48+
{
49+
$user = $this->model->where("public_id", $public_id)->firstOrFail();
50+
51+
return new UserResource($user);
52+
}
53+
54+
public function update(UpdateUserRequest $request, string $public_id)
55+
{
56+
$user = $this->model->where("public_id", $public_id)->firstOrFail();
57+
58+
Cache::forget('users');
59+
60+
$user->update($request->validated());
61+
62+
return response()->json(['message' => 'updated']);
63+
}
64+
65+
public function destroy(string $public_id)
66+
{
67+
$user = $this->model->where("public_id", $public_id)->firstOrFail();
68+
$user->delete();
69+
70+
Cache::forget('users');
71+
72+
return response()->json([], 204);
73+
}
74+
}

app/Http/Controllers/Controller.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
abstract class Controller
6+
{
7+
//
8+
}
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\Requests\User;
4+
5+
use Illuminate\Foundation\Http\FormRequest;
6+
use Illuminate\Support\Str;
7+
8+
class StoreUserRequest extends FormRequest
9+
{
10+
/**
11+
* Determine if the user is authorized to make this request.
12+
*/
13+
public function authorize()
14+
{
15+
return true;
16+
}
17+
18+
/**
19+
* Handle a passed validation attempt.
20+
*/
21+
protected function passedValidation(): void
22+
{
23+
$this->merge([
24+
'public_id' => Str::uuid(),
25+
]);
26+
}
27+
28+
/**
29+
* Get the validation rules that apply to the request.
30+
*
31+
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
32+
*/
33+
public function rules(): array
34+
{
35+
return [
36+
'name' => ['required', 'min:3', 'max:255', "unique:courses,name"],
37+
'description' => ['nullable', 'min:3', 'max:9999'],
38+
];
39+
}
40+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace App\Http\Requests\User;
4+
5+
use Illuminate\Foundation\Http\FormRequest;
6+
7+
class UpdateUserRequest extends FormRequest
8+
{
9+
/**
10+
* Determine if the user is authorized to make this request.
11+
*/
12+
public function authorize()
13+
{
14+
return true;
15+
}
16+
17+
/**
18+
* Get the validation rules that apply to the request.
19+
*
20+
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
21+
*/
22+
public function rules(): array
23+
{
24+
$public_id = $this->course;
25+
26+
return [
27+
'name' => ['required', 'min:3', 'max:255', "unique:courses,name,{$public_id},public_id"],
28+
'description' => ['nullable', 'min:3', 'max:9999'],
29+
];
30+
}
31+
}

0 commit comments

Comments
 (0)