From d7dd54427106d9236f04cf2b7e98abf58ca7ff16 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 24 Aug 2020 19:51:19 +1000 Subject: [PATCH] System logs --- .../Controllers/OpenAPI/SystemLogSchema.php | 2 +- app/Http/Controllers/SystemLogController.php | 94 +++++++++++++++++-- app/Models/SystemLog.php | 10 ++ .../2014_10_13_000000_create_users_table.php | 10 +- 4 files changed, 102 insertions(+), 14 deletions(-) diff --git a/app/Http/Controllers/OpenAPI/SystemLogSchema.php b/app/Http/Controllers/OpenAPI/SystemLogSchema.php index 6e800ca4f0e9..dd1a1cb18517 100644 --- a/app/Http/Controllers/OpenAPI/SystemLogSchema.php +++ b/app/Http/Controllers/OpenAPI/SystemLogSchema.php @@ -10,7 +10,7 @@ * @OA\Property(property="event_id", type="int", example="1", description="The Log Type ID"), * @OA\Property(property="category_id", type="int", example="1", description="The Category Type ID"), * @OA\Property(property="type_id", type="int", example="1", description="The Type Type ID"), - * @OA\Property(property="log", type="object", example="{"key":"value"}", description="The json object of the error"), + * @OA\Property(property="log", type="object", example="{'key':'value'}", description="The json object of the error"), * @OA\Property(property="updated_at", type="string", example="2", description="______"), * @OA\Property(property="created_at", type="string", example="2", description="______"), * ) diff --git a/app/Http/Controllers/SystemLogController.php b/app/Http/Controllers/SystemLogController.php index de17eba8d089..ae4e83ae461b 100644 --- a/app/Http/Controllers/SystemLogController.php +++ b/app/Http/Controllers/SystemLogController.php @@ -72,7 +72,13 @@ class SystemLogController extends Controller */ public function create() { - // + $error = [ + 'message' => 'Cannot create system log', + 'errors' => new \stdClass + ]; + + + return response()->json($error, 400); } /** @@ -83,18 +89,72 @@ class SystemLogController extends Controller */ public function store(Request $request) { - // + + $error = [ + 'message' => 'Cannot store system log', + 'errors' => new \stdClass + ]; + + + return response()->json($error, 400); + } /** * Display the specified resource. * - * @param int $id + * @param \App\Http\Requests\Invoice\ShowInvoiceRequest $request The request + * @param \App\Models\SystemLog $system_logs The system logs + * * @return \Illuminate\Http\Response + * + * + * @OA\Get( + * path="/api/v1/system_logs/{id}", + * operationId="showSystemLogs", + * tags={"system_logs"}, + * summary="Shows a system_logs", + * description="Displays a system_logs by id", + * @OA\Parameter(ref="#/components/parameters/X-Api-Secret"), + * @OA\Parameter(ref="#/components/parameters/X-Api-Token"), + * @OA\Parameter(ref="#/components/parameters/X-Requested-With"), + * @OA\Parameter(ref="#/components/parameters/include"), + * @OA\Parameter( + * name="id", + * in="path", + * description="The system_logs Hashed ID", + * example="D2J234DFA", + * required=true, + * @OA\Schema( + * type="string", + * format="string", + * ), + * ), + * @OA\Response( + * response=200, + * description="Returns the system_logs object", + * @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"), + * @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"), + * @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"), + * @OA\JsonContent(ref="#/components/schemas/SystemLog"), + * ), + * @OA\Response( + * response=422, + * description="Validation error", + * @OA\JsonContent(ref="#/components/schemas/ValidationError"), + * + * ), + * @OA\Response( + * response="default", + * description="Unexpected Error", + * @OA\JsonContent(ref="#/components/schemas/Error"), + * ), + * ) + * */ - public function show($id) + public function show(Request $request, SystemLog $system_log) { - // + return $this->itemResponse($system_log); } /** @@ -105,7 +165,13 @@ class SystemLogController extends Controller */ public function edit($id) { - // + $error = [ + 'message' => 'Cannot edit system log', + 'errors' => new \stdClass + ]; + + + return response()->json($error, 400); } /** @@ -117,7 +183,13 @@ class SystemLogController extends Controller */ public function update(Request $request, $id) { - // + $error = [ + 'message' => 'Cannot update system log', + 'errors' => new \stdClass + ]; + + + return response()->json($error, 400); } /** @@ -128,6 +200,12 @@ class SystemLogController extends Controller */ public function destroy($id) { - // + $error = [ + 'message' => 'Cannot destroy system log', + 'errors' => new \stdClass + ]; + + + return response()->json($error, 400); } } diff --git a/app/Models/SystemLog.php b/app/Models/SystemLog.php index f7b517314226..490a4c104b17 100644 --- a/app/Models/SystemLog.php +++ b/app/Models/SystemLog.php @@ -54,4 +54,14 @@ class SystemLog extends Model protected $casts = [ 'log' => 'array' ]; + + public function resolveRouteBinding($value) + { + if (is_numeric($value)) { + throw new ModelNotFoundException("Record with value {$value} not found"); + } + + return $this + ->where('id', $this->decodePrimaryKey($value))->firstOrFail(); + } } diff --git a/database/migrations/2014_10_13_000000_create_users_table.php b/database/migrations/2014_10_13_000000_create_users_table.php index 1141ee17b48d..2dda97aaabdf 100644 --- a/database/migrations/2014_10_13_000000_create_users_table.php +++ b/database/migrations/2014_10_13_000000_create_users_table.php @@ -481,7 +481,7 @@ class CreateUsersTable extends Migration $t->boolean('custom_surcharge_tax3')->default(false); $t->boolean('custom_surcharge_tax4')->default(false); - $t->decimal('exchange_rate', 16, 4); + $t->decimal('exchange_rate', 13, 6)->default(1); $t->decimal('amount', 16, 4); $t->decimal('balance', 16, 4); $t->decimal('partial', 16, 4)->nullable(); @@ -559,7 +559,7 @@ class CreateUsersTable extends Migration $t->boolean('custom_surcharge_tax3')->default(false); $t->boolean('custom_surcharge_tax4')->default(false); - $t->decimal('exchange_rate', 16, 4); + $t->decimal('exchange_rate', 13, 6)->default(1); $t->decimal('amount', 16, 4); $t->decimal('balance', 16, 4); $t->decimal('partial', 16, 4)->nullable(); @@ -803,7 +803,7 @@ class CreateUsersTable extends Migration $t->boolean('custom_surcharge_tax3')->default(false); $t->boolean('custom_surcharge_tax4')->default(false); - $t->decimal('exchange_rate', 16, 4); + $t->decimal('exchange_rate', 13, 6)->default(1); $t->decimal('amount', 16, 4); $t->decimal('balance', 16, 4); $t->decimal('partial', 16, 4)->nullable(); @@ -964,7 +964,7 @@ class CreateUsersTable extends Migration $t->softDeletes('deleted_at', 6); $t->boolean('is_deleted')->default(false); $t->boolean('is_manual')->default(false); - $t->decimal('exchange_rate', 16, 6)->default(1); + $t->decimal('exchange_rate', 13, 6)->default(1); $t->unsignedInteger('currency_id'); $t->unsignedInteger('exchange_currency_id'); @@ -1297,7 +1297,7 @@ class CreateUsersTable extends Migration $table->boolean('is_deleted')->default(false); $table->decimal('amount', 13, 2); $table->decimal('foreign_amount', 13, 2); - $table->decimal('exchange_rate', 13, 4); + $table->decimal('exchange_rate', 13, 6)->default(1); $table->string('tax_name1')->nullable(); $table->decimal('tax_rate1', 13, 3)->default(0); $table->string('tax_name2')->nullable();