Skip to content

Commit

Permalink
Merge branch 'main' into #10-regulations-for-escooters
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee0z authored May 6, 2024
2 parents 30a9b44 + 0900bd0 commit 638c09c
Show file tree
Hide file tree
Showing 36 changed files with 1,151 additions and 580 deletions.
13 changes: 4 additions & 9 deletions app/Http/Controllers/CityOpinionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,19 @@

use App\Http\Requests\CityOpinionRequest;
use App\Models\CityOpinion;
use Illuminate\Support\Facades\Auth;

class CityOpinionController extends Controller
{
public function store(CityOpinionRequest $request): void
{
$opinion = $request->only(["rating", "content", "city_id"]);
$opinion["user_id"] = Auth::id();

CityOpinion::query()->create($opinion);
$request->user()
->cityOpinions()
->create($request->validated());
}

public function update(CityOpinionRequest $request, CityOpinion $cityOpinion): void
{
$opinion = $request->only(["rating", "content", "city_id"]);
$opinion["user_id"] = Auth::id();

$cityOpinion->update($opinion);
$cityOpinion->update($request->validated());
}

public function destroy(CityOpinion $cityOpinion): void
Expand Down
1 change: 1 addition & 0 deletions app/Importers/DataImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ protected function deleteMissingProviders(string $providerName, array $existingC
->whereNotIn("city_id", $existingCityProviders)
->whereNot("created_by", "admin")
->get();

$cityProvidersToDelete->each(fn($cityProvider) => $cityProvider->delete());
}

Expand Down
21 changes: 21 additions & 0 deletions app/Policies/CityOpinionPolicy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace App\Policies;

use App\Models\CityOpinion;
use App\Models\User;

class CityOpinionPolicy
{
public function update(User $user, CityOpinion $cityOpinion): bool
{
return $cityOpinion->user_id === $user->id;
}

public function delete(User $user, CityOpinion $cityOpinion): bool
{
return $cityOpinion->user_id === $user->id || $user->hasRole("admin");
}
}
4 changes: 4 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

namespace App\Providers;

use App\Models\CityOpinion;
use App\Policies\CityOpinionPolicy;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
use Laravel\Sanctum\PersonalAccessToken;
use Laravel\Sanctum\Sanctum;
Expand All @@ -28,6 +31,7 @@ public function register(): void
public function boot(): void
{
JsonResource::withoutWrapping();
Gate::policy(CityOpinion::class, CityOpinionPolicy::class);
Sanctum::usePersonalAccessTokenModel(PersonalAccessToken::class);
}
}
7 changes: 7 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docker-compose.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ services:
condition: service_healthy

database:
image: postgres:15.2-alpine3.17
image: postgres:15.6-alpine3.19
container_name: escooters-db-staging
environment:
- POSTGRES_USER=${DB_USERNAME}
Expand All @@ -64,7 +64,7 @@ services:
restart: unless-stopped

redis:
image: redis:7.0.11-alpine3.17
image: redis:7.2.4-alpine3.19
container_name: escooters-redis-staging
ports:
- ${DOCKER_REDIS_HOST_PORT:-3852}:6379
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ services:
condition: service_healthy

database:
image: postgres:15.2-alpine3.17
image: postgres:15.6-alpine3.19
container_name: escooters-db-dev
environment:
- POSTGRES_USER=${DB_USERNAME}
Expand All @@ -72,7 +72,7 @@ services:
restart: unless-stopped

mailpit:
image: axllent/mailpit:v1.6.9
image: axllent/mailpit:v1.16
container_name: escooters-mailpit-dev
labels:
- "traefik.enable=true"
Expand All @@ -95,7 +95,7 @@ services:
- ${DOCKER_MAILPIT_DASHBOARD_HOST_PORT:-3856}:8025

redis:
image: redis:7.0.11-alpine3.17
image: redis:7.2.4-alpine3.19
container_name: escooters-redis-dev
ports:
- ${DOCKER_REDIS_HOST_PORT:-3852}:6379
Expand Down
4 changes: 2 additions & 2 deletions environment/dev/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM composer/composer:2.6.6-bin as composer-bin
FROM composer/composer:2.7.2-bin as composer-bin

FROM node:21.4.0-bullseye-slim as node
FROM node:21.7.1-bullseye-slim as node

FROM php:8.3.3-fpm-bullseye

Expand Down
4 changes: 2 additions & 2 deletions environment/staging/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM composer/composer:2.6.6-bin as composer-bin
FROM composer/composer:2.7.2-bin as composer-bin

FROM node:20.4.0-bullseye-slim as node
FROM node:21.7.1-bullseye-slim as node

FROM php:8.3.3-fpm-bullseye

Expand Down
Loading

0 comments on commit 638c09c

Please sign in to comment.