Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
249 commits
Select commit Hold shift + click to select a range
9fdf587
Switch to php 8
idanieldrew Sep 19, 2022
ee4a02e
Fix ci
idanieldrew Sep 19, 2022
a84825f
Fix ci 2
idanieldrew Sep 19, 2022
b8b71c1
Migrate to laravel 9
idanieldrew Sep 19, 2022
4a4a74f
Migrate to laravel 9
idanieldrew Sep 19, 2022
44d7a01
Delete composer.lock
idanieldrew Sep 21, 2022
576c74c
Migrate docker to php 8
idanieldrew Sep 22, 2022
3299da1
Fix ci?
idanieldrew Sep 23, 2022
b5991a2
Migrate to php 8.1
idanieldrew Sep 23, 2022
d57c971
index posts for search(elastic engine)
idanieldrew Sep 26, 2022
bd5f608
index posts for search(elastic engine)
idanieldrew Sep 26, 2022
178a4fd
Merge branch 'feature/elastic' into develop
idanieldrew Sep 27, 2022
6080c6f
Add details to elastic
idanieldrew Sep 27, 2022
ca672a2
indeed fix ci
idanieldrew Sep 29, 2022
45eb245
indeed fix ci
idanieldrew Sep 29, 2022
83dd3f4
add elastic to ci
idanieldrew Oct 1, 2022
3f85510
fix elastic1
idanieldrew Oct 1, 2022
5c22c45
fix elastic 2
idanieldrew Oct 1, 2022
01d084d
add container ci
idanieldrew Oct 2, 2022
2b5b9ee
add container ci 2
idanieldrew Oct 2, 2022
c034e01
add container ci 3
idanieldrew Oct 2, 2022
5c158d8
add container ci 4
idanieldrew Oct 2, 2022
f84c0e1
add container ci 5
idanieldrew Oct 2, 2022
9c3352b
add container ci 6
idanieldrew Oct 2, 2022
f78c96f
Change dockerfile
idanieldrew Oct 3, 2022
4d34d62
Change dockerfile 2
idanieldrew Oct 3, 2022
3a71fa1
Change dockerfile 3
idanieldrew Oct 3, 2022
403a3e6
Change dockerfile 4
idanieldrew Oct 3, 2022
1d2e38b
Change dockerfile 5
idanieldrew Oct 3, 2022
829ec3e
Edit dockerfile
idanieldrew Oct 3, 2022
7b41867
Edit docker
idanieldrew Oct 3, 2022
b216bbd
Edit docker 2
idanieldrew Oct 3, 2022
d1ac202
Edit docker 3
idanieldrew Oct 3, 2022
51b1e83
Edit docker 4
idanieldrew Oct 3, 2022
01685df
Edit docker 5
idanieldrew Oct 3, 2022
3eecccb
Test ci
idanieldrew Oct 4, 2022
3f98bd7
Test ci 2
idanieldrew Oct 4, 2022
1c01abc
Test ci 3
idanieldrew Oct 4, 2022
43283d0
Test ci 4
idanieldrew Oct 4, 2022
3914e9e
Test ci 5
idanieldrew Oct 4, 2022
e184831
see lists
idanieldrew Oct 4, 2022
f0e8135
Test ci 6
idanieldrew Oct 4, 2022
fe30081
Test ci 7
idanieldrew Oct 4, 2022
1f28710
Test ci 8
idanieldrew Oct 4, 2022
79317ff
Test ci
idanieldrew Oct 4, 2022
dde9903
Test ci 10
idanieldrew Oct 4, 2022
8a2c463
Test ci 11
idanieldrew Oct 4, 2022
f8cb401
Test ci 12
idanieldrew Oct 4, 2022
dd764b8
Test ci 13
idanieldrew Oct 4, 2022
7e4a496
Test ci 14
idanieldrew Oct 4, 2022
582e3c7
Test ci 15
idanieldrew Oct 4, 2022
b98bede
Test ci 16
idanieldrew Oct 4, 2022
2850b61
Test ci 17
idanieldrew Oct 4, 2022
4631a3b
Test ci 18
idanieldrew Oct 4, 2022
c6ae8ed
Test ci 19
idanieldrew Oct 4, 2022
32def4f
Test
idanieldrew Oct 4, 2022
15a0260
Test 2
idanieldrew Oct 4, 2022
2b3dd90
Test 3
idanieldrew Oct 4, 2022
03f1ddc
Test 4
idanieldrew Oct 4, 2022
40806d2
Test 5
idanieldrew Oct 4, 2022
f372545
Test 6
idanieldrew Oct 4, 2022
732cffa
check user
idanieldrew Oct 5, 2022
cc5c2d2
check user
idanieldrew Oct 5, 2022
4525f36
check user 2
idanieldrew Oct 5, 2022
014239c
Test permission
idanieldrew Oct 6, 2022
b2480f6
Test permission 2
idanieldrew Oct 6, 2022
5386f93
Test ci
idanieldrew Oct 6, 2022
fe0f255
Test ci 2
idanieldrew Oct 6, 2022
f0bfba3
Test ci 3
idanieldrew Oct 6, 2022
cb10906
Update Dockerfile
idanieldrew Oct 6, 2022
0ddfd6a
Update containers.yml
idanieldrew Oct 6, 2022
fb2b668
Update containers.yml
idanieldrew Oct 6, 2022
fcaaceb
Update .env.docker.ci
idanieldrew Oct 6, 2022
7acd460
Update containers.yml
idanieldrew Oct 6, 2022
e9f97bd
Update containers.yml
idanieldrew Oct 6, 2022
cfbb125
Update containers.yml
idanieldrew Oct 6, 2022
0944ea5
Update containers.yml
idanieldrew Oct 7, 2022
b507949
Update docker-compose.yml
idanieldrew Oct 7, 2022
cf6933c
Update Dockerfile
idanieldrew Oct 7, 2022
98c0cad
Update containers.yml
idanieldrew Oct 7, 2022
57e3ba2
Update docker-compose.yml
idanieldrew Oct 7, 2022
76ebe5b
Fixing
idanieldrew Oct 7, 2022
dc5bbe5
Test sudo
idanieldrew Oct 7, 2022
cb88b45
Fix sudo
idanieldrew Oct 7, 2022
10ca372
Fix 1
idanieldrew Oct 7, 2022
e02ab1b
Fix 2
idanieldrew Oct 7, 2022
f4c3cc8
Fix 3
idanieldrew Oct 7, 2022
f82c48f
Update docker-compose.yml
idanieldrew Oct 8, 2022
8eea412
Update containers.yml
idanieldrew Oct 8, 2022
e9271d2
Update Dockerfile
idanieldrew Oct 8, 2022
cab8070
Update Dockerfile
idanieldrew Oct 8, 2022
80c2426
Update containers.yml
idanieldrew Oct 8, 2022
f043425
Update containers.yml
idanieldrew Oct 8, 2022
9561fc3
Update containers.yml
idanieldrew Oct 8, 2022
72a42d0
Update containers.yml
idanieldrew Oct 8, 2022
6586009
Update containers.yml
idanieldrew Oct 8, 2022
a41b651
fix ci 1
idanieldrew Oct 9, 2022
7786971
use elastic in query
idanieldrew Oct 10, 2022
02e374c
use elastic in query
idanieldrew Oct 10, 2022
0efd464
Add other post for single post
idanieldrew Oct 12, 2022
393b934
Fix tests
idanieldrew Oct 15, 2022
b5c9d33
Fix tests
idanieldrew Oct 15, 2022
4cc6bab
test slug should english in category module
idanieldrew Oct 15, 2022
2da845f
readme 1
idanieldrew Oct 16, 2022
17b9a0c
Add docs 1
idanieldrew Oct 18, 2022
cc884b2
Test ci
idanieldrew Oct 19, 2022
8c3fd00
Test ci 2
idanieldrew Oct 19, 2022
d01be73
Rm docker tests
idanieldrew Oct 19, 2022
26a08f9
Update tests.yml
idanieldrew Oct 22, 2022
2873c18
Update tests.yml
idanieldrew Oct 22, 2022
2da6501
Update tests.yml
idanieldrew Oct 22, 2022
e0fd0c8
Update tests.yml
idanieldrew Oct 22, 2022
92d0b2a
Update tests.yml
idanieldrew Oct 22, 2022
afce136
Update tests.yml
idanieldrew Oct 22, 2022
d6cc463
Update tests.yml
idanieldrew Oct 22, 2022
f40a8b4
Update tests.yml
idanieldrew Oct 22, 2022
35dcf6e
Update tests.yml
idanieldrew Oct 22, 2022
3df1c90
Update explorer.php
idanieldrew Oct 22, 2022
1291fae
Update explorer.php
idanieldrew Oct 22, 2022
dab4f8e
Update explorer.php
idanieldrew Oct 22, 2022
0c6242f
Update tests.yml
idanieldrew Oct 22, 2022
ea6ffe7
Update explorer.php
idanieldrew Oct 22, 2022
80aec7e
Update tests.yml
idanieldrew Oct 22, 2022
9061ebc
Update explorer.php
idanieldrew Oct 22, 2022
4394ce7
Fix update users test
idanieldrew Oct 24, 2022
a12e282
Impoer index
idanieldrew Oct 25, 2022
5914380
Impoer index 2
idanieldrew Oct 25, 2022
44ca6b6
Impoer index 3
idanieldrew Oct 25, 2022
5e94dc2
fix env example ci
idanieldrew Oct 25, 2022
38d2866
fix env example ci 2
idanieldrew Oct 25, 2022
b3d2d33
Fix configs
idanieldrew Oct 28, 2022
2ef3fd7
Some works
idanieldrew Oct 29, 2022
7b262aa
cleaning post.show and write api it
idanieldrew Oct 30, 2022
4fa162f
Fix not found err
idanieldrew Oct 31, 2022
4805548
Fix search posts
idanieldrew Oct 31, 2022
f88a5a2
change composer details
idanieldrew Nov 1, 2022
63128c9
update readme
idanieldrew Nov 1, 2022
b6d24ea
Create LICENSE
idanieldrew Nov 1, 2022
702d366
Merge pull request #1 from idanieldrew/add-license-1
idanieldrew Nov 1, 2022
3d7dea4
Add apiDoc & fix xdebug
idanieldrew Nov 7, 2022
acfa41f
start Status module
idanieldrew Nov 7, 2022
3c5223b
Add verification doc
idanieldrew Nov 8, 2022
2c084be
Add verification doc
idanieldrew Nov 8, 2022
c6e4290
fix ci
idanieldrew Nov 8, 2022
ced7363
edit md
idanieldrew Nov 8, 2022
29dc776
edit md
idanieldrew Nov 8, 2022
1d5d02e
remove token field in users table
idanieldrew Nov 10, 2022
85a585d
abstract verify
idanieldrew Nov 12, 2022
cbaee63
Send mail suucessfully(step 1)
idanieldrew Nov 13, 2022
8f1176f
Send mail suucessfully(step 2)
idanieldrew Nov 13, 2022
624ea21
Fix ci
idanieldrew Nov 14, 2022
15a0909
Fix ci
idanieldrew Nov 14, 2022
4aa06e7
Fix ci 2
idanieldrew Nov 14, 2022
ca20f65
Fix ci 3
idanieldrew Nov 14, 2022
1462ead
Add rabbitmq for queue
idanieldrew Nov 15, 2022
ec951af
Add horizon
idanieldrew Nov 15, 2022
ac1732c
Add horizon
idanieldrew Nov 15, 2022
85507df
r
idanieldrew Nov 16, 2022
9819a01
Seperate auth & user module
idanieldrew Nov 17, 2022
cba992a
Fix user observer
idanieldrew Nov 18, 2022
6f6ca3a
Update readme
idanieldrew Nov 18, 2022
00fe142
Video driver for media module
idanieldrew Nov 19, 2022
f1e1748
Complete verify job
idanieldrew Nov 21, 2022
2eef204
Change column name
idanieldrew Nov 21, 2022
80ad3b1
scheduling_work_1
idanieldrew Nov 22, 2022
99f7a5d
Change dir job
idanieldrew Nov 26, 2022
1ce232a
Premium module
idanieldrew Nov 26, 2022
40ba5c9
some works for premium module
idanieldrew Nov 26, 2022
7c88a88
Fix plans_1
idanieldrew Dec 4, 2022
6fdf89c
plan tables
idanieldrew Dec 5, 2022
fd24264
store plan
idanieldrew Dec 6, 2022
c344b9b
Fix tests
idanieldrew Dec 7, 2022
3aa9a21
Add some features
idanieldrew Dec 7, 2022
ae3d24d
Fix db
idanieldrew Dec 10, 2022
6eeee7e
enable opcache(default setting)
idanieldrew Dec 10, 2022
af603e3
Seperate validation
idanieldrew Dec 18, 2022
04d1809
tset
idanieldrew Dec 19, 2022
7cb5caa
Add uuid
idanieldrew Dec 20, 2022
8fc8fb4
Fix elastic and xdebug
idanieldrew Dec 24, 2022
bf7a8c5
Fix ci
idanieldrew Dec 24, 2022
e4e8cbb
Add logstash
idanieldrew Dec 24, 2022
bc4721a
Fix elastic and add logstash
idanieldrew Jan 1, 2023
b8fe126
Remove publish field in posts db
idanieldrew Jan 3, 2023
1a2f763
update readme
idanieldrew Jan 3, 2023
b249610
Reply license post
idanieldrew Jan 8, 2023
84f4302
license post test
idanieldrew Jan 10, 2023
9a52f6e
Fix failed job for rabbitmq
idanieldrew Jan 10, 2023
c08338f
forget password_1
idanieldrew Jan 19, 2023
cc3fc68
forget password_2
idanieldrew Jan 21, 2023
1472bee
forget password_3
idanieldrew Jan 21, 2023
c473109
forget password-3
idanieldrew Jan 22, 2023
6ee4c11
forget password-4
idanieldrew Jan 22, 2023
da2d1dd
forget password-5
idanieldrew Jan 22, 2023
8833e55
add docker-compose for tests
idanieldrew Jan 22, 2023
0d80f4e
Rempve temprory logstash image
idanieldrew Jan 23, 2023
980f9db
update ci
idanieldrew Jan 23, 2023
e122d2d
update ci 2
idanieldrew Jan 23, 2023
02e09e7
update ci 3
idanieldrew Jan 23, 2023
0913575
update ci 4
idanieldrew Jan 23, 2023
0bd35cc
update ci 5
idanieldrew Jan 23, 2023
d53e0f0
update ci 6
idanieldrew Jan 23, 2023
277760f
update ci 7
idanieldrew Jan 23, 2023
9a446cb
update ci 8
idanieldrew Jan 23, 2023
4eb8485
update ci 9
idanieldrew Jan 23, 2023
4f39932
update ci 10
idanieldrew Jan 23, 2023
e2867dc
update ci 11
idanieldrew Jan 23, 2023
4c69f9f
update ci 12
idanieldrew Jan 23, 2023
aa74e67
Update composer.json
idanieldrew Jan 23, 2023
e533773
add pcntl
idanieldrew Jan 29, 2023
9df15bc
add pcntl
idanieldrew Jan 29, 2023
5a0cf2a
rm docker ci
idanieldrew Jan 29, 2023
522cec3
Fix style with pint
idanieldrew Jan 30, 2023
ad615e3
Start pusher
idanieldrew Feb 5, 2023
1b6915c
add env
idanieldrew Feb 5, 2023
9ceb8ba
Fix env.ci
idanieldrew Feb 6, 2023
e880a92
Add pusher in requirements
idanieldrew Feb 6, 2023
323964f
Add optimize:clear to ci
idanieldrew Feb 6, 2023
84f9550
Change brodcast driver in test
idanieldrew Feb 6, 2023
656e98c
Add some tests for forget psd
idanieldrew Feb 15, 2023
6128c09
Add verify_forget_psd tests
idanieldrew Feb 20, 2023
e387886
Add filebeat image
idanieldrew Feb 21, 2023
5d0be7f
Fix elastic
idanieldrew Feb 21, 2023
09d8313
Change psd
idanieldrew Feb 22, 2023
dae10ed
Add rate limit for post
idanieldrew Feb 27, 2023
dd7f5f6
Add minio & ffmpeg for downloading
idanieldrew Mar 5, 2023
29923f7
Add stream
idanieldrew Mar 5, 2023
87f0507
Add batch jobs and fix tests
idanieldrew Mar 8, 2023
3629d8c
Add minio
idanieldrew Mar 12, 2023
87f25bc
Add filebeat & send logs to elastic
idanieldrew Mar 14, 2023
1584ff1
Update es,kibana,fileb to 8.6
idanieldrew Mar 28, 2023
2cf28df
Complete filebeat
idanieldrew Mar 29, 2023
cdffc02
Add tus
idanieldrew Apr 5, 2023
f5e30a9
sentry
idanieldrew Apr 8, 2023
fb29d90
Fix bugs
idanieldrew Apr 9, 2023
e303e4e
Test for jenkins
idanieldrew Apr 28, 2023
ad9ea83
Add pest & write some tests
idanieldrew May 4, 2023
94db04b
Update readme
idanieldrew May 18, 2023
66675fc
fix bugs
idanieldrew Jun 29, 2023
5bc975a
fix bugs 2
idanieldrew Jun 29, 2023
196f5a7
Add horizon to readme
idanieldrew Jul 1, 2023
743d725
Add kibana to readme
idanieldrew Jul 2, 2023
1dcf231
Add larastan
idanieldrew Sep 14, 2023
ea27a5d
Add php stan
idanieldrew Sep 14, 2023
09ddcf9
Fix response in phpstan
idanieldrew Sep 15, 2023
e792943
Fix response in phpstan 2
idanieldrew Sep 15, 2023
31f4aca
Fix some issues type
idanieldrew Sep 15, 2023
0ad9d81
Fix return types
idanieldrew Sep 20, 2023
196bda4
Setup prometheus
idanieldrew Oct 11, 2023
27d32eb
Add postgres exporter
idanieldrew Oct 21, 2023
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
60 changes: 30 additions & 30 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,49 +1,35 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:RiWBp49nfpfayJpARxkxdBXKRSrLnVDvq3UjAuW4qWQ=
APP_KEY=
APP_DEBUG=true
APP_URL=http://127.0.0.1:8000

LOG_CHANNEL=stack
LOG_LEVEL=debug

# docker
# DB_CONNECTION="pgsql"
# DB_HOST=mediumdb
# DB_PORT=5432
# DB_DATABASE=medium
# DB_USERNAME="dani"
# DB_PASSWORD="password"

# mysql
DB_CONNECTION="mysql"
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=blog
DB_USERNAME="daniel"
DB_PASSWORD="Password123#@!"

BROADCAST_DRIVER=log
DB_CONNECTION="pgsql"
DB_HOST=redact_db
DB_PORT=5432
DB_DATABASE=postgres
DB_USERNAME="dani"
DB_PASSWORD="password"

BROADCAST_DRIVER=pusher
CACHE_DRIVER=redis
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=redis
# SESSION_DRIVER=file
# SESSION_LIFETIME=120
FILESYSTEM_DRIVER=minio
QUEUE_CONNECTION=rabbitmq

# REDIS_HOST=redis
# REDIS_PASSWORD=
# REDIS_PORT=6379

REDIS_HOST=mediumredis
REDIS_HOST="redact_cache"
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=3e3ff464db3fda
MAIL_PASSWORD=aec248ea70249a
MAIL_ENCRYPTION=tls
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
Expand All @@ -54,7 +40,21 @@ AWS_USE_PATH_STYLE_ENDPOINT=false
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

SCOUT_DRIVER="elastic"
SCOUT_QUEUE=true

ELASTIC_HOST="redact_elastic"
RABBITMQ_HOST="redact_rabbitmq"

CUSTOM_ELASTIC_IP=172.19.0.30
CUSTOM_KIBANA_IP=172.19.0.40
CUSTOM_MINIO_IP=172.19.0.20
SUBNET=172.19.0.0/16
13 changes: 7 additions & 6 deletions .env.example.ci
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
APP_NAME=Laravel
APP_ENV=local
APP_NAME=redact
APP_ENV=staging
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_URL=http://127.0.0.1

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

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

BROADCAST_DRIVER=log
CACHE_DRIVER=file
Expand Down Expand Up @@ -57,3 +57,4 @@ VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

ELASTIC_HOST="localhost"
39 changes: 31 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
name: Tests

on: [ push, pull_request ]

jobs:
laravel-blog:
redact:
runs-on: ubuntu-latest
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.4.0
env:
discovery.type: single-node
options: >-
--name mediumElasticsearch
--hostname mediumElasticsearch
--health-cmd "curl http://localhost:9200/_cluster/health"
--health-interval 10s
--health-timeout 5s
--health-retries 10
ports:
- 9200:9200
mysql-service:
image: mysql:5.7
env:
Expand All @@ -18,25 +29,35 @@ jobs:
--health-interval=10s
--health-timeout=5s
--health-retries=3

steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Verify Elasticsearch connection from host
env:
ELASTIC_SEARCH_URL: http://localhost:${{ job.services.elasticsearch.ports[9200] }}
run: |
echo $ELASTIC_SEARCH_URL
curl -fsSL "$ELASTIC_SEARCH_URL/_cat/health?h=status"
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.1
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
coverage: none

- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction

- name: Copy environment file
run: cp .env.example.ci .env

- name: Generate app key
run: php artisan key:generate
- name: Optimization
run: php artisan optimize:clear
- name: Migration
run: php artisan migrate:fresh --seed
- name: Import indexes
run: php artisan scout:index posts
- name: Import db
run: php artisan scout:import "Module\Post\Models\Post"
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_CONNECTION: mysql
Expand All @@ -46,3 +67,5 @@ jobs:
DB_PASSWORD: password
run:
php artisan test
# - name: Run php stan
# run: ./vendor/bin/phpstan analyse --memory-limit=2G
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Daniel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
67 changes: 67 additions & 0 deletions Modules/Auth/Http/Controllers/v1/AuthController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

namespace Module\Auth\Http\Controllers\v1;

use App\Http\Controllers\Controller;
use Illuminate\Auth\Events\Registered;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Http\Response;
use Illuminate\Support\Collection;
use Module\Auth\Http\Requests\v1\LoginRequest;
use Module\Auth\Http\Requests\v1\RegisterRequest;
use Module\Auth\Services\v1\AuthService;
use Module\Share\Contracts\Response\ResponseGenerator;
use Module\User\Http\Resources\v1\UserResource;

class AuthController extends Controller implements ResponseGenerator
{
private AuthService $service;

public function __construct()
{
$this->service = resolve(AuthService::class);
}

/**
* Register user
*
* @param RegisterRequest $request
* @return JsonResponse $this->response($status,$message,$data)
*/
public function register(RegisterRequest $request)
{
$res = $this->service->store($request);

// verification by mail
event(new Registered($res['user']));

return $this->res('success', Response::HTTP_CREATED, 'Successfully register', $res);
}

/**
* Login user
*
* @param LoginRequest $request
* @return JsonResponse $this->response($status,$message,$data)
*/
public function login(LoginRequest $request)
{
$res = $this->service->login($request);

return $this->res($res[0], $res[1], $res[2], $res[3]);
}

public function res(string $status, int $code, string|null $message, array|int|ResourceCollection|JsonResource $data = null): JsonResponse
{
return response()->json([
'status' => $status,
'message' => $message,
'data' => ! $data ? null : [
'user' => new UserResource($data['user']),
'token' => $data['token'],
],
], $code);
}
}
33 changes: 33 additions & 0 deletions Modules/Auth/Http/Controllers/v1/VerifyController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Module\Auth\Http\Controllers\v1;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\EmailVerificationRequest;
use Illuminate\Http\Request;

class VerifyController extends Controller
{
/**
* @param EmailVerificationRequest $request
* @return string
*/
public function verify(EmailVerificationRequest $request)
{
$request->fulfill();

return 'ok,verify it';
}

/**
* @param Request $request
* @return mixed
*/
public function send(Request $request)
{
return null;
/*$request->user()->sendEmailVerificationNotification();

return 'send it';*/
}
}
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
<?php

namespace Module\User\Http\Controllers\auth\v2;
namespace Module\Auth\Http\Controllers\v2;

use App\Http\Controllers\Controller;
use Illuminate\Auth\Events\Registered;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Support\Collection;
use Module\Auth\Http\Requests\v2\LoginRequest;
use Module\Auth\Http\Requests\v2\RegisterRequest;
use Module\Auth\Services\v2\AuthService;
use Module\Share\Contracts\Response\ResponseGenerator;
use Module\User\Http\Requests\v2\LoginRequest;
use Module\User\Http\Requests\v2\RegisterRequest;
use Module\User\Http\Resources\v2\UserResource;
use Module\User\Services\v2\UserService;

class AuthController extends Controller implements ResponseGenerator
{
private $service;
private AuthService $service;

public function __construct()
{
$this->service = resolve(UserService::class);
$this->service = resolve(AuthService::class);
}

/**
* Register user
* @param \Module\User\Http\Requests\v2\RegisterRequest $request
* @return \Illuminate\Http\JsonResponse
*
* @param RegisterRequest $request
* @return JsonResponse
*/
public function register(RegisterRequest $request)
{
$store = $this->service->store($request);

event(new Registered($store['data']['user']));

return $this->res($store['status'], $store['code'], $store['message'], $store['data']);
}

/**
* Login user
* @param \Module\User\Http\Requests\v2\LoginRequest $request
* @return \Illuminate\Http\JsonResponse $this->response($status,$message,$data)
*
* @param LoginRequest $request
* @return JsonResponse $this->response($status,$message,$data)
*/
public function login(LoginRequest $request): \Illuminate\Http\JsonResponse
{
Expand All @@ -47,15 +48,15 @@ public function login(LoginRequest $request): \Illuminate\Http\JsonResponse
return $this->res($login['status'], $login['code'], $login['message'], $login['data']);
}

public function res($status, $code, $message, $data = null): \Illuminate\Http\JsonResponse
public function res(string $status, int $code, string|null $message, array|int|ResourceCollection|JsonResource $data = null): JsonResponse
{
return response()->json([
'status' => $status,
'message' => $message,
'data' => !$data ? null : [
'data' => ! $data ? null : [
'user' => new UserResource($data['user']),
'token' => $data['token']
]
'token' => $data['token'],
],
], $code);
}
}
Loading