Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
40.00% |
2 / 5 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ClientTypesController | |
40.00% |
2 / 5 |
|
50.00% |
1 / 2 |
4.94 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| list_client_types | |
25.00% |
1 / 4 |
|
0.00% |
0 / 1 |
3.69 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Controllers; |
| 4 | |
| 5 | use App\Models\ClientType; |
| 6 | use Illuminate\Support\Facades\App; |
| 7 | use App\Exceptions\AppException; |
| 8 | |
| 9 | class ClientTypesController extends Controller |
| 10 | { |
| 11 | public function __construct() |
| 12 | { |
| 13 | App::setLocale(request()->header('Locale-Id')); |
| 14 | } |
| 15 | |
| 16 | /** |
| 17 | * GET /client-types |
| 18 | * List all client types ordered by sort_order. |
| 19 | */ |
| 20 | function list_client_types() |
| 21 | { |
| 22 | try { |
| 23 | return ClientType::orderByRaw('ISNULL(sort_order), sort_order ASC')->get(); |
| 24 | |
| 25 | } catch (\Exception $e) { |
| 26 | report(AppException::fromException($e, 'LIST_CLIENT_TYPES_EXCEPTION')); |
| 27 | return response(['message' => 'KO', 'error' => $e->getMessage()]); |
| 28 | } |
| 29 | } |
| 30 | } |