change code for new position
This commit is contained in:
@@ -6,9 +6,12 @@ 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\HarimOffice\FileRejectedRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\HarimOffice\FileAcceptedRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\HarimOffice\RejectRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\HarimOffice\ShowRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\HarimOffice\YesRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\HarimOffice\NoRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\HarimOffice\NeedRoadAccessRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\HarimOffice\WithoutRoadAccessRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\Harim;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -21,19 +24,50 @@ class HarimOfficeController extends Controller
|
||||
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$user = auth()->user();
|
||||
$query = Harim::query()
|
||||
->where('state_id','=',HarimStates::BARESI_TAVASOT_DAFTAR_HARIM->value)
|
||||
->where('edareh_shahri_id', '=', $user->edarate_shahri_id);
|
||||
->whereIn('state_id', [
|
||||
HarimStates::BARESI_TAVASOT_DAFTAR_HARIM->value,
|
||||
HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_DAFTAR_HARIM->value,
|
||||
])
|
||||
->where('edareh_shahri_id', '=', auth()->user()->edarate_shahri_id);
|
||||
|
||||
$data = DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
);
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
public function yes(YesRequest $request, Harim $harim ): JsonResponse
|
||||
|
||||
|
||||
public function rejectRequest(RejectRequest $request, Harim $harim): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request, $harim) {
|
||||
$action = HarimAction::NO->value;
|
||||
$harim->histories()->create([
|
||||
'expert_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_TAVASOT_MOAVEN->value;
|
||||
|
||||
$harim->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
'is_possible' => false,
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
|
||||
public function needRoadAccess(NeedRoadAccessRequest $request, Harim $harim): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request,$harim) {
|
||||
$action = HarimAction::YES->value;
|
||||
@@ -51,12 +85,15 @@ class HarimOfficeController extends Controller
|
||||
$harim ->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
'final_description' => 'yes'
|
||||
'is_possible' => true,
|
||||
'need_road_access' => true,
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
}
|
||||
public function no(NoRequest $request, Harim $harim ): JsonResponse
|
||||
|
||||
|
||||
public function withoutRoadAccess(WithoutRoadAccessRequest $request, Harim $harim): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request,$harim) {
|
||||
$action = HarimAction::NO->value;
|
||||
@@ -74,7 +111,54 @@ class HarimOfficeController extends Controller
|
||||
$harim ->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
'final_description' => 'no'
|
||||
'is_possible' => true,
|
||||
'need_road_access' => false,
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
}
|
||||
public function fileAccepted(FileAcceptedRequest $request, Harim $harim): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request,$harim) {
|
||||
$action = HarimAction::YES->value;
|
||||
$harim->histories()->create([
|
||||
'expert_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_FILE_APLODE_SHODE_TAVASOTE_MOAVEN->value;
|
||||
|
||||
$harim ->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
'is_file_good' => true,
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
}
|
||||
public function fileRejected(FileRejectedRequest $request, Harim $harim): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request,$harim) {
|
||||
$action = HarimAction::NO->value;
|
||||
$harim->histories()->create([
|
||||
'expert_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_FILE_APLODE_SHODE_TAVASOTE_MOAVEN->value;
|
||||
|
||||
$harim ->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
'is_file_good' => false,
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
|
||||
@@ -7,12 +7,14 @@ 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\Requests\V3\Dashboard\Harim\Deputy\ConfirmRoadAccessRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\Deputy\ReferRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\Deputy\ReferRoadAccessRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\Deputy\ShowRequest;
|
||||
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
|
||||
@@ -20,11 +22,12 @@ 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');
|
||||
->whereIn('state_id', [
|
||||
HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_MOAVEN->value,
|
||||
HarimStates::BARESI_TAVASOT_MOAVEN->value,
|
||||
])
|
||||
->where('edare_shahri_id', '=', auth()->user()->edarate_shahri_id);
|
||||
|
||||
$data = DataTableFacade::run(
|
||||
$query,
|
||||
@@ -32,9 +35,10 @@ class TechnicalDeputyController extends Controller
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
);
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
public function conform(ConfirmRequest $request, Harim $harim): JsonResponse
|
||||
public function conformRequest(ConfirmRequest $request, Harim $harim): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request,$harim) {
|
||||
$action = HarimAction::CONFIRM->value;
|
||||
@@ -47,20 +51,21 @@ class TechnicalDeputyController extends Controller
|
||||
'action_id' => $action,
|
||||
'action_name' => HarimAction::name($action),
|
||||
]);
|
||||
$state = HarimStates::Baresi_Imeni_Rah_Tavasot_Modir_Kol->value;
|
||||
|
||||
$state = HarimStates::BARESI_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
|
||||
public function referRequest(ReferRequest $request, Harim $harim): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request,$harim) {
|
||||
$action = HarimAction::REJECT->value;
|
||||
$action = HarimAction::REFER->value;
|
||||
|
||||
$harim->histories()->create([
|
||||
'expert_id' => auth()->user()->id,
|
||||
@@ -70,7 +75,54 @@ class TechnicalDeputyController extends Controller
|
||||
'action_id' => $action,
|
||||
'action_name' => HarimAction::name($action),
|
||||
]);
|
||||
$state = HarimStates::Baresi_Imeni_Rah_Tavasot_Daftar_Harim->value;
|
||||
|
||||
$state = HarimStates::BARESI_TAVASOT_DAFTAR_HARIM->value;
|
||||
|
||||
$harim->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
}
|
||||
public function confirmRoadAccess(ConfirmRoadAccessRequest $request, Harim $harim): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request, $harim) {
|
||||
$action = HarimAction::CONFIRM->value;
|
||||
$harim->histories()->create([
|
||||
'expert_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_FILE_APLODE_SHODE_TAVASOTE_MODIR_KOL->value;
|
||||
|
||||
$harim->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function referRoadAccess(ReferRoadAccessRequest $request, Harim $harim): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request, $harim) {
|
||||
$action = HarimAction::REFER->value;
|
||||
$harim->histories()->create([
|
||||
'expert_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_FILE_APLODE_SHODE_TAVASOTE_DAFTAR_HARIM->value;
|
||||
|
||||
$harim->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
|
||||
Reference in New Issue
Block a user