Skip to content

Commit

Permalink
v0.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
DestroyCom committed Sep 7, 2023
2 parents 22af83b + b24c5c0 commit 2556530
Show file tree
Hide file tree
Showing 20 changed files with 449 additions and 109 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_web_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
tag_with_latest: true
path: ./sera-front/
build_file: ./prod.Dockerfile
extra_args: --build-arg port=80 --build-arg VITE_BACKEND_URL=https://sera-api.destcom.website --build-arg VITE_ENV_MODE=production
extra_args: --build-arg port=80 --build-arg VITE_BACKEND_URL=https://sera-api.stroyco.eu --build-arg VITE_ENV_MODE=production
4 changes: 2 additions & 2 deletions develop.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ services:
target: runner
args:
- port=${PORT_FRONT:-80}
- VITE_BACKEND_URL=${ENV_VARIABLE:-https://develop-sera-back.destcom.website}
- VITE_ENV_MODE=${VITE_ENV_MODE:-dev}
- VITE_BACKEND_URL=${ENV_VARIABLE:-https://develop-sera-back.stroyco.eu}
- VITE_ENV_MODE=${VITE_ENV_MODE:-development}
networks:
- monolith
- hosted
Expand Down
6 changes: 3 additions & 3 deletions sera-back/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ AWS_SECRET_ACCESS_KEY=${MINIO_ROOT_PASSWORD}
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=sera
AWS_USE_PATH_STYLE_ENDPOINT=true
AWS_ENDPOINT_URL=http://minio:9000
AWS_URL=http://minio:9000
AWS_ENDPOINT=http://minio:9000
AWS_ENDPOINT_URL=http://localhost:9000
AWS_URL=http://localhost:9000
AWS_ENDPOINT=http://localhost:9000
#
PUSHER_APP_ID=
PUSHER_APP_KEY=
Expand Down
86 changes: 86 additions & 0 deletions sera-back/app/Http/Controllers/NotificationController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

namespace App\Http\Controllers;

use App\Models\Notification;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class NotificationController extends Controller
{
public function index()
{
$user = Auth::user();
$notifications = Notification::where('user_id', $user->id)->get();

return response()->json($notifications, 201);
}

public function store(Request $request)
{
$validated = $request->validate([
'title' => 'required|string',
'description' => 'required|string',
'is_urgent' => 'required|boolean',
]);

$notification = new Notification();
$notification->title = $$validated['title'];
$notification->description = $validated['description'];
$notification->is_read = false;
$notification->is_deleted = false;
$notification->user_id = Auth::user()->id;
$notification->is_urgent = $validated['is_urgent'];
$notification->save();

return response()->json($notification, 201);
}

public function show($id)
{
$notification = Notification::find($id);
return response()->json($notification);
}

public function update(Request $request)
{
$validated = $request->validate([
'title' => 'string',
'description' => 'string',
'is_urgent' => 'boolean',
'is_read' => 'boolean'
]);

$notification = Notification::find($request->id);

if ($notification == null) {
return response()->json(['error' => 'Notification not found.'], 404);
}

if ($request->filled('title')) {
$notification->title = $validated['title'];
}
if ($request->filled('description')) {
$notification->description = $validated['description'];
}
if ($request->filled('is_urgent')) {
$notification->is_urgent = $validated['is_urgent'];
}

$notification->save();
return response()->json($notification, 201);
}

public function destroy($id)
{
$notification = Notification::find($id);

if ($notification == null) {
return response()->json(['error' => 'Notification not found.'], 404);
}

$notification->delete();

return response()->json('Notification deleted successfully', 201);
}
}
Loading

0 comments on commit 2556530

Please sign in to comment.