2026-06-23 10:10:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Modules\Client\Actions;
|
|
|
|
|
|
|
|
|
|
use App\Modules\Client\Models\Client;
|
2026-07-18 09:34:18 +00:00
|
|
|
use Illuminate\Database\Eloquent\Collection;
|
2026-06-23 10:10:28 +00:00
|
|
|
|
|
|
|
|
final class GetClientAction
|
|
|
|
|
{
|
2026-07-18 09:34:18 +00:00
|
|
|
public function list(): Collection
|
2026-06-23 10:10:28 +00:00
|
|
|
{
|
2026-07-18 09:34:18 +00:00
|
|
|
return Client::query()
|
|
|
|
|
->withCount('historyEntries')
|
|
|
|
|
->withMax('historyEntries', 'created_at')
|
|
|
|
|
->orderBy('name')
|
|
|
|
|
->get();
|
2026-06-23 10:10:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function find(int $id): Client
|
|
|
|
|
{
|
2026-07-18 09:34:18 +00:00
|
|
|
return Client::with('customFieldValues.author')->findOrFail($id);
|
2026-06-23 10:10:28 +00:00
|
|
|
}
|
|
|
|
|
}
|