Compare commits
1 Commits
14925f6cb5
...
db4a058b5e
Author | SHA1 | Date |
---|---|---|
philipp lang | db4a058b5e |
|
@ -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' => []
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\User\Actions;
|
||||
|
||||
use App\Http\Resources\UserResource;
|
||||
use App\User;
|
||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class IndexAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
public function handle(): AnonymousResourceCollection
|
||||
{
|
||||
return UserResource::collection(User::orderByRaw('lastname, firstname')->get());
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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:
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Permission;
|
||||
|
||||
use App\User;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\TestCase;
|
||||
|
||||
class UserIndexTest extends TestCase
|
||||
{
|
||||
|
||||
use DatabaseTransactions;
|
||||
|
||||
public function testItListsUsers(): void
|
||||
{
|
||||
$this->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');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue