Skip to content

Commit

Permalink
add site update
Browse files Browse the repository at this point in the history
  • Loading branch information
pachonjcl committed May 10, 2024
1 parent 02ecb8f commit c8cd3c2
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
35 changes: 35 additions & 0 deletions app/Http/Controllers/V2/Sites/AdminSitesUpdateStatusController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace App\Http\Controllers\V2\Sites;

use App\Http\Controllers\Controller;
use App\Http\Controllers\Traits\IsAdminIndex;
use App\Models\V2\AuditStatus\AuditStatus;
use App\Models\V2\Sites\Site;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;

class AdminSitesUpdateStatusController extends Controller
{
use IsAdminIndex;

public function __invoke(Request $request, string $uuid): Site
{
$site = Site::where('uuid', $uuid)->first();
$body = $request->all();
$site['status']= $body['status'];
$site->update();

AuditStatus::create([
'entity' => $this->getModel($site),
'entity_uuid' => $site->uuid,
'status' => $body['status'],
'comment' => $body['comment'],
// 'attachment_url' => $body['attachment_url'],
'date_created' => now(),
'created_by' => Auth::user()->email_address,
]);

return $site;
}
}
50 changes: 50 additions & 0 deletions resources/docs/swagger-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44378,6 +44378,29 @@ definitions:
type: string
num_trees:
type: integer
SiteStatusRequestPost:
type: object
properties:
status:
type: string
comment:
type: string
SiteStatusResponse:
type: object
properties:
entity_uuid:
type: string
status:
type: string
comment:
type: string
attachment_url:
type: string
date_created:
type: string
format: date
created_by:
type: string
AuditStatusResponse:
type: object
properties:
Expand Down Expand Up @@ -90562,6 +90585,33 @@ paths:
'200':
description: OK
'/v2/admin/sites/{UUID}':
put:
operationId: put-v2-admin-sites-uuid
summary: update site status
tags:
- V2 Sites
parameters:
- in: path
name: UUID
required: true
type: string
description: The UUID of the site
requestBody:
content:
application/json:
schema:
$ref: '#/definitions/SiteStatusRequestPost'
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/definitions/SiteStatusResponse'
'400':
description: Bad request
'500':
description: Internal server error
delete:
summary: Delete a site
operationId: delete-v2-admin-site-UUID
Expand Down
2 changes: 2 additions & 0 deletions routes/api_v2.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
use App\Http\Controllers\V2\SiteReports\SiteReportsViaSiteController;
use App\Http\Controllers\V2\Sites\AdminIndexSitesController;
use App\Http\Controllers\V2\Sites\AdminSitesMultiController;
use App\Http\Controllers\V2\Sites\AdminSitesUpdateStatusController;
use App\Http\Controllers\V2\Sites\CreateSiteWithFormController;
use App\Http\Controllers\V2\Sites\Monitoring\AdminCreateSiteMonitoringController;
use App\Http\Controllers\V2\Sites\Monitoring\AdminSoftDeleteSiteMonitoringController;
Expand Down Expand Up @@ -302,6 +303,7 @@

Route::prefix('sites')->group(function () {
Route::get('/', AdminIndexSitesController::class);
Route::put('/{site}', AdminSitesUpdateStatusController::class);
Route::get('/multi', AdminSitesMultiController::class);
});

Expand Down

0 comments on commit c8cd3c2

Please sign in to comment.