diff --git a/app/Http/Resources/UserResource.php b/app/Http/Resources/UserResource.php index 21ced1d7..898441d9 100644 --- a/app/Http/Resources/UserResource.php +++ b/app/Http/Resources/UserResource.php @@ -2,6 +2,7 @@ namespace App\Http\Resources; +use App\Lib\HasMeta; use App\User; use Illuminate\Http\Resources\Json\JsonResource; use Storage; @@ -11,6 +12,8 @@ use Storage; */ class UserResource extends JsonResource { + use HasMeta; + /** * Transform the resource into an array. * @@ -25,9 +28,17 @@ class UserResource extends JsonResource 'lastname' => $this->lastname, 'avatar_url' => $this->getGravatarUrl(), 'email' => $this->email, + 'id' => $this->id, 'avatar' => [ 'src' => Storage::url('avatar.png'), ], ]; } + + public static function meta(): array + { + return [ + 'links' => [] + ]; + } } diff --git a/app/User/Actions/IndexAction.php b/app/User/Actions/IndexAction.php new file mode 100644 index 00000000..d6461057 --- /dev/null +++ b/app/User/Actions/IndexAction.php @@ -0,0 +1,18 @@ +get()); + } +} diff --git a/bin/copydbdk b/bin/copydbdk new file mode 100755 index 00000000..8dc253dd --- /dev/null +++ b/bin/copydbdk @@ -0,0 +1,5 @@ +#!/bin/bash + +ssh dkd 'cd $ADREMA_PATH && docker compose exec db mysqldump -q -udb -p'$ADREMA_DB_PASSWORD' db --ignore-table=db.telescope_entries --ignore-table=db.failed_jobs' > db.tmp +sudo mysql scoutrobot < db.tmp + diff --git a/bin/testmigration b/bin/testmigration new file mode 100755 index 00000000..0db5877f --- /dev/null +++ b/bin/testmigration @@ -0,0 +1,7 @@ +#!/usr/bin/zsh + +php artisan migrate:fresh --env=testing +ssh dkd 'cd $ADREMA_PATH && docker compose exec db mysqldump -q -udb -p'$ADREMA_DB_PASSWORD' db --ignore-table=db.telescope_entries --ignore-table=db.failed_jobs' > dddd.sql +sudo mysql scoutrobottest < dddd.sql +php artisan migrate --env=testing + diff --git a/docker-compose.yml b/docker-compose.yml index aa27c717..50c63b6b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -92,6 +92,8 @@ services: socketi: image: quay.io/soketi/soketi:89604f268623cf799573178a7ba56b7491416bde-16-debian + ports: + - '6001:6001' environment: SOKETI_DEFAULT_APP_ID: adremaid SOKETI_DEFAULT_APP_KEY: adremakey @@ -104,6 +106,8 @@ services: meilisearch: image: getmeili/meilisearch:v1.6 + ports: + - '7700:7700' volumes: - ./data/meilisearch:/meili_data env_file: diff --git a/routes/api.php b/routes/api.php index 9e751f3a..47a709ef 100644 --- a/routes/api.php +++ b/routes/api.php @@ -6,6 +6,7 @@ use App\Form\Actions\RegisterAction; use App\Prevention\Actions\SettingStoreAction as PreventionStoreAction; use App\Group\Actions\GroupApiIndexAction; use App\Prevention\Actions\SettingApiAction; +use App\User\Actions\IndexAction as UserIndexAction; Route::post('/contribution-generate', ContributionGenerateApiAction::class)->name('api.contribution.generate')->middleware('client:contribution-generate'); Route::post('/form/{form}/register', RegisterAction::class)->name('form.register'); @@ -13,3 +14,4 @@ Route::get('/group/{group?}', GroupApiIndexAction::class)->name('api.group'); Route::get('/form', FormApiListAction::class)->name('api.form.index'); Route::get('/prevention', SettingApiAction::class)->name('api.prevention.index'); Route::post('/prevention', PreventionStoreAction::class)->name('api.prevention.store'); +Route::get('/user', UserIndexAction::class)->name('api.user.index'); diff --git a/tests/Feature/Permission/UserIndexTest.php b/tests/Feature/Permission/UserIndexTest.php new file mode 100644 index 00000000..84af2df9 --- /dev/null +++ b/tests/Feature/Permission/UserIndexTest.php @@ -0,0 +1,27 @@ +login()->loginNami(); + auth()->user()->update(['firstname' => 'Jane', 'lastname' => 'Doe']); + User::factory()->create(['firstname' => 'John', 'lastname' => 'Doe']); + $anna = User::factory()->create(['firstname' => 'Anna', 'lastname' => 'Doe']); + $this->get(route('api.user.index')) + ->assertJsonPath('data.0.firstname', 'Anna') + ->assertJsonPath('data.0.lastname', 'Doe') + ->assertJsonPath('data.0.id', $anna->id) + ->assertJsonPath('data.1.firstname', 'Jane') + ->assertJsonPath('data.2.firstname', 'John'); + } +}