changes
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\Dashboard\UI\WEB\Controllers;
|
||||
|
||||
use App\Containers\Dashboard\Actions\Posts\DeploySiteAction;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class DeployController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly DeploySiteAction $deploySiteAction,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Запускает деплой (создаёт файл-триггер)
|
||||
*/
|
||||
public function deploy(Request $request): JsonResponse
|
||||
{
|
||||
if (app()->environment() !== 'production') {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Деплой доступен только на production',
|
||||
], 403);
|
||||
}
|
||||
|
||||
if (!$request->user()->hasRole('admin')) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Недостаточно прав для выполнения этой операции',
|
||||
], 403);
|
||||
}
|
||||
|
||||
$result = $this->deploySiteAction->run();
|
||||
|
||||
return response()->json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверяет статус деплоя
|
||||
*/
|
||||
public function status(Request $request): JsonResponse
|
||||
{
|
||||
if (app()->environment() !== 'production') {
|
||||
return response()->json(['status' => 'disabled'], 403);
|
||||
}
|
||||
|
||||
if (!$request->user()->hasRole('admin')) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Недостаточно прав',
|
||||
], 403);
|
||||
}
|
||||
|
||||
$status = $this->deploySiteAction->getStatus();
|
||||
|
||||
return response()->json($status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Очищает статус деплоя
|
||||
*/
|
||||
public function clear(Request $request): JsonResponse
|
||||
{
|
||||
if (!$request->user()->hasRole('admin')) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Недостаточно прав',
|
||||
], 403);
|
||||
}
|
||||
|
||||
$this->deploySiteAction->clearStatus();
|
||||
|
||||
return response()->json(['success' => true]);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ use App\Containers\Dashboard\UI\WEB\Controllers\CategoryController as NewsCatego
|
||||
use App\Containers\Dashboard\UI\WEB\Controllers\ContactWidgetController;
|
||||
use App\Containers\Dashboard\UI\WEB\Controllers\CreateSliderController;
|
||||
use App\Containers\Dashboard\UI\WEB\Controllers\CustomFormController;
|
||||
use App\Containers\Dashboard\UI\WEB\Controllers\DeployController;
|
||||
use App\Containers\Dashboard\UI\WEB\Controllers\DepartmentController;
|
||||
use App\Containers\Dashboard\UI\WEB\Controllers\PageReferenceListController;
|
||||
use App\Containers\Dashboard\UI\WEB\Controllers\DepartmentProgramController;
|
||||
@@ -60,6 +61,9 @@ Route::post('/dashboard/logout', [AuthenticatedSessionController::class, 'destro
|
||||
// Authenticated dashboard routes
|
||||
Route::middleware(['access-check', 'dashboard.auth'])->group(function () {
|
||||
Route::get('/dashboard', IndexDashboardController::class)->name('dashboard.index');
|
||||
Route::post('/dashboard/deploy', [DeployController::class, 'deploy'])->name('dashboard.deploy');
|
||||
Route::get('/dashboard/deploy/status', [DeployController::class, 'status'])->name('dashboard.deploy.status');
|
||||
Route::post('/dashboard/deploy/clear', [DeployController::class, 'clear'])->name('dashboard.deploy.clear');
|
||||
|
||||
// CRUD постов
|
||||
Route::prefix('/dashboard/posts')->name('dashboard.posts.')->group(function () {
|
||||
|
||||
Reference in New Issue
Block a user