Skip to content

Commit

Permalink
feat: add params uuid and entity required
Browse files Browse the repository at this point in the history
  • Loading branch information
LimberHope committed May 9, 2024
1 parent 3c74622 commit 331e5e7
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ public function __invoke(Request $request, string $id = null)
$auditStatus = AuditStatus::where('id', $id)->first();

return new AuditStatusResource($auditStatus);
} else if ($request->has('entity')) {
} else if ($request->has('entity') && $request->has('uuid')) {
$auditStatus = AuditStatus::where('entity_uuid', $request->input('entity'))
->where('uuid', $request->input('uuid'))
->orderBy('updated_at', 'desc')
->orderBy('created_at', 'desc')
->get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
use App\Http\Requests\V2\StoreAuditStatusRequest;
use App\Http\Resources\V2\AuditStatusResource;
use App\Models\V2\AuditStatus\AuditStatus;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;

class StoreAuditStatusController extends Controller
{
public function __invoke(StoreAuditStatusRequest $storeAuditStatusRequest): AuditStatusResource
{
$auditStatus = AuditStatus::create($storeAuditStatusRequest->all());
$auditStatus = new AuditStatus($storeAuditStatusRequest->all());
$auditStatus->date_created = now();
$auditStatus->save();

return new AuditStatusResource($auditStatus);
}
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Requests/V2/StoreAuditStatusRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ class StoreAuditStatusRequest extends FormRequest
public function rules()
{
return [
'entity' => ['sometimes', 'string', 'nullable', 'max:256'],
'entity_uuid' => ['sometimes', 'string', 'nullable', 'max:256'],
'status' => ['sometimes', 'string', 'nullable', 'max:256'],
'comment' => ['sometimes', 'string', 'nullable', 'max:500'],
'attachment_url' => ['sometimes', 'string', 'nullable', 'max:256'],
'date_created' => ['sometimes', 'date'],
'created_by' => ['sometimes', 'string', 'nullable', 'max:256'],
];
}
}
3 changes: 1 addition & 2 deletions app/Http/Requests/V2/UpdateAuditStatusRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ class UpdateAuditStatusRequest extends FormRequest
public function rules()
{
return [
'entity' => ['sometimes', 'string', 'nullable', 'max:256'],
'entity_uuid' => ['sometimes', 'string', 'nullable', 'max:256'],
'status' => ['sometimes', 'string', 'nullable', 'max:256'],
'comment' => ['sometimes', 'string', 'nullable', 'max:500'],
'attachment_url' => ['sometimes', 'string', 'nullable', 'max:256'],
'date_created' => ['sometimes', 'date'],
'created_by' => ['sometimes', 'string', 'nullable', 'max:256'],
];
}
}
1 change: 1 addition & 0 deletions app/Http/Resources/V2/AuditStatusResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function toArray($request)
{
return [
'id' => $this->id,
'entity' => $this->entity,
'entity_uuid' => $this->entity_uuid,
'status' => $this->status,
'comment' => $this->comment,
Expand Down
1 change: 1 addition & 0 deletions app/Models/V2/AuditStatus/AuditStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class AuditStatus extends Model

protected $fillable = [
'id',
'entity',
'entity_uuid',
'status',
'comment',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function up()
Schema::dropIfExists('status');
Schema::create('status', function (Blueprint $table) {
$table->id();
$table->string('entity')->nullable();
$table->string('entity_uuid')->nullable();
$table->string('status')->nullable();
$table->string('comment')->nullable();
Expand Down
8 changes: 7 additions & 1 deletion resources/docs/swagger-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94524,7 +94524,13 @@ paths:
- in: query
name: entity
type: string
description: Optional.
required: true
description: required.
- in: query
name: uuid
type: string
required: true
description: required.
responses:
'200':
description: OK
Expand Down
10 changes: 5 additions & 5 deletions routes/api_v2.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@
use App\Http\Controllers\V2\ProjectPipeline\GetProjectPipelineController;
use App\Http\Controllers\V2\ProjectPipeline\StoreProjectPipelineController;
use App\Http\Controllers\V2\ProjectPipeline\UpdateProjectPipelineController;
use App\Http\Controllers\V2\AuditStatus\DeleteAuditStatusController;
// use App\Http\Controllers\V2\AuditStatus\DeleteAuditStatusController;
use App\Http\Controllers\V2\AuditStatus\GetAuditStatusController;
use App\Http\Controllers\V2\AuditStatus\StoreAuditStatusController;
use App\Http\Controllers\V2\AuditStatus\UpdateAuditStatusController;
// use App\Http\Controllers\V2\AuditStatus\UpdateAuditStatusController;
use App\Http\Controllers\V2\ProjectPitches\AdminIndexProjectPitchController;
use App\Http\Controllers\V2\ProjectPitches\DeleteProjectPitchController;
use App\Http\Controllers\V2\ProjectPitches\ExportProjectPitchController;
Expand Down Expand Up @@ -709,8 +709,8 @@ function () {

Route::prefix('audit-status')->group(function () {
Route::get('/', GetAuditStatusController::class);
Route::get('/{id}', GetAuditStatusController::class);
Route::post('/', StoreAuditStatusController::class);
Route::put('/{id}', UpdateAuditStatusController::class);
Route::delete('/{id}', DeleteAuditStatusController::class);
// Route::get('/{id}', GetAuditStatusController::class);
// Route::put('/{id}', UpdateAuditStatusController::class);
// Route::delete('/{id}', DeleteAuditStatusController::class);
});

0 comments on commit 331e5e7

Please sign in to comment.