create controller and these dependensi
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\Harim;
|
||||
|
||||
use App\Enums\HarimAction;
|
||||
use App\Enums\HarimStates;
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\GeneralManager\ConfirmRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\GeneralManager\RejectRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\Harim;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class GeneralManagerController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$user = auth()->user();
|
||||
$query = Harim::query()
|
||||
->where('state_id','=',HarimStates::Baresi_Imeni_Rah_Tavasot_Modir_Kol->value)
|
||||
->where('edare_shahri_id', '=', $user->edarate_shahri_id)
|
||||
->with('histories:expert_description');
|
||||
|
||||
$data = DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*']
|
||||
);
|
||||
return response()->json($data);
|
||||
}
|
||||
public function conform(ConfirmRequest $request, Harim $harim): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request, $harim) {
|
||||
$action = HarimAction::CONFIRM->value;
|
||||
$harim->histories()->create([
|
||||
'user_id' => auth()->user()->id,
|
||||
'previous_state_id' => $harim->state_id,
|
||||
'previous_state_name' => $harim->state_name,
|
||||
'expert_description' => $request->expert_description,
|
||||
'action_id' => $action,
|
||||
'action_name' => HarimAction::name($action),
|
||||
]);
|
||||
|
||||
$state = HarimStates::ERSAL_BE_PANJAREVAHED->value;
|
||||
$harim->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function reject(RejectRequest $request, Harim $harim): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request, $harim) {
|
||||
$action = HarimAction::REJECT->value;
|
||||
$harim->histories()->create([
|
||||
'user_id'=> auth()->user()->id,
|
||||
'previous-state_id' => $harim->state_id,
|
||||
'previous_state_name' => $harim->state_name,
|
||||
'export_description' => $request->export_description,
|
||||
'action_id' => $action,
|
||||
'action_name' => HarimAction::name($action),
|
||||
]);
|
||||
$state = HarimStates::Baresi_Imeni_Rah_Tavasot_Moaven->value;
|
||||
$harim->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
}
|
||||
public function show(Harim $harim): JsonResponse
|
||||
{
|
||||
return $this->successResponse($harim);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,11 @@ class HarimOfficeController extends Controller
|
||||
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = Harim::query()->where('edareh_shahri_id', '=', auth()->user()->edarate_shahri_id);
|
||||
$user = auth()->user();
|
||||
$query = Harim::query()
|
||||
->where('state_id','=',HarimStates::Baresi_Imeni_Rah_Tavasot_Daftar_Harim->value)
|
||||
->where('edare_shahri_id', '=', $user->edarate_shahri_id)
|
||||
->with('expert_description');
|
||||
$data = DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
@@ -47,6 +51,7 @@ class HarimOfficeController extends Controller
|
||||
$harim ->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
'final_description' => 'yes'
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
@@ -69,6 +74,7 @@ class HarimOfficeController extends Controller
|
||||
$harim ->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
'final_description' => 'no'
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
|
||||
@@ -20,7 +20,10 @@ class ProvinceOfficeController extends Controller
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$user = auth()->user();
|
||||
$query = Harim::query()->where('edareh_shahri_id', '=', $user->edarate_shahri_id);
|
||||
$query = Harim::query()
|
||||
->where('state_id','=',HarimStates::Baresi_Edare_Shahrestan->value)
|
||||
->where('edare_shahri_id', '=', $user->edarate_shahri_id);
|
||||
|
||||
$data = DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
@@ -33,13 +36,15 @@ class ProvinceOfficeController extends Controller
|
||||
public function feedback(FeedBackRequest $request, Harim $harim): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request,$harim) {
|
||||
$action = HarimAction::FEEDBACK->value;
|
||||
|
||||
$harim->histories()->create([
|
||||
'user_id' => auth()->user()->id,
|
||||
'previous_state_id' => $harim->state_id,
|
||||
'previous_state_name' => $harim->state_name,
|
||||
'expert_description' => $request->expert_description,
|
||||
'action_id' => HarimAction::FEEDBACK->value,
|
||||
'action_name' => HarimAction::FEEDBACK->name,
|
||||
'action_id' => $action,
|
||||
'action_name' => HarimAction::name($action),
|
||||
]);
|
||||
|
||||
$state = HarimStates::Baresi_Imeni_Rah_Tavasot_Daftar_Harim->value;
|
||||
@@ -55,6 +60,5 @@ class ProvinceOfficeController extends Controller
|
||||
public function show(Harim $harim): JsonResponse
|
||||
{
|
||||
return $this->successResponse($harim);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\Harim;
|
||||
|
||||
use App\Enums\HarimAction;
|
||||
use App\Enums\HarimStates;
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\Deputy\ConfirmRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\Harim;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class TechnicalDeputyController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$user = auth()->user();
|
||||
$query = Harim::query()
|
||||
->where('state_id', '=', HarimStates::Baresi_Imeni_Rah_Tavasot_Moaven->value)
|
||||
->where('edare_shahri_id', '=', $user->edarate_shahri_id)
|
||||
->with('histories:expert_description');
|
||||
|
||||
$data = DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
);
|
||||
return response()->json($data);
|
||||
}
|
||||
public function conform(ConfirmRequest $request, Harim $harim): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request,$harim) {
|
||||
$action = HarimAction::CONFIRM->value;
|
||||
|
||||
$harim->histories()->create([
|
||||
'user_id' => auth()->user()->id,
|
||||
'previous_state_id' => $harim->state_id,
|
||||
'previous_state_name' => $harim->state_name,
|
||||
'expert_description' => $request->expert_description,
|
||||
'action_id' => $action,
|
||||
'action_name' => HarimAction::name($action),
|
||||
]);
|
||||
$state = HarimStates::Baresi_Imeni_Rah_Tavasot_Modir_Kol->value;
|
||||
|
||||
$harim ->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
|
||||
}
|
||||
public function reject(ConfirmRequest $request, Harim $harim): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request,$harim) {
|
||||
$action = HarimAction::REJECT->value;
|
||||
|
||||
$harim->histories()->create([
|
||||
'user_id' => auth()->user()->id,
|
||||
'previous_state_id' => $harim->state_id,
|
||||
'previous_state_name' => $harim->state_name,
|
||||
'expert_description' => $request->expert_description,
|
||||
'action_id' => $action,
|
||||
'action_name' => HarimAction::name($action),
|
||||
]);
|
||||
$state = HarimStates::Baresi_Imeni_Rah_Tavasot_Daftar_Harim->value;
|
||||
$harim->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
}
|
||||
public function show(Harim $harim): JsonResponse
|
||||
{
|
||||
return $this->successResponse($harim);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user