Merge branch 'feature/MissionController' into 'develop'
create controller See merge request witelgroup/rms_v2!113
This commit is contained in:
28
app/Enums/MissionStates.php
Normal file
28
app/Enums/MissionStates.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum MissionStates: int
|
||||
{
|
||||
case REQUEST_CREATED= 1;
|
||||
case PENDING_CONFIRMATION = 2;
|
||||
case START_MISSION = 3;
|
||||
|
||||
case END_MISSION = 4;
|
||||
case REJECT_BY_TRANSPORTATION = 5;
|
||||
case REJECT_BY_CONTROL_UNIT = 6;
|
||||
|
||||
public static function name(int $state): string
|
||||
{
|
||||
$mapArray = [
|
||||
1 => 'درخواست ایجاد شد و در حال بررسی در توسط واحد نقلیه است',
|
||||
2 => 'خودرو اختصاص داده شد و درخواست توسط واحد کنترل در حال بررسی است',
|
||||
3 => 'درخواست توسط واحد کنترل تایید شد و ماموریت آغاز می شود',
|
||||
4 => 'اتمام ماموریت',
|
||||
5 => 'عدم تخصیص خودرو توسط واحد نقلیه و بازگشت درخواست به کارتابل کاربر',
|
||||
6 => 'عدم تایید توسط واحد کنترل',
|
||||
];
|
||||
|
||||
return $mapArray[$state];
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\Mission;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CartableController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\Mission;
|
||||
|
||||
use App\Enums\MissionStates;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\Mission\RequestPortal\StoreRequest;
|
||||
use App\Http\Requests\V3\Mission\RequestPortal\UpdateRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\Mission;
|
||||
use App\Services\Cartables\Mission\RequestPortalService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class RequestPortalController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function index(Request $request, RequestPortalService $requestPortalService): JsonResponse
|
||||
{
|
||||
return response()->json($requestPortalService->datatable($request));
|
||||
}
|
||||
|
||||
public function store(StoreRequest $request): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request) {
|
||||
$state = MissionStates::REQUEST_CREATED->value;
|
||||
$mission = Mission::query()->create([
|
||||
'user_id'=> auth()->user()->id,
|
||||
'state_id' =>$state,
|
||||
'state_name' => MissionStates::name($state),
|
||||
'requested_machine_type' => $request->requested_machine_type,
|
||||
'requested_machine_numbers' => $request->requested_machine_numbers,
|
||||
'type' => $request->type,
|
||||
'start_date' => $request->start_date,
|
||||
'end_date' => $request->end_date,
|
||||
'request_date' => $request->request_date,
|
||||
'description' => $request->description,
|
||||
'start_point' => $request->start_point,
|
||||
'end_point' => $request->end_point,
|
||||
]);
|
||||
|
||||
$mission->rahdaran()->attach($request->rahdaran);
|
||||
});
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function show(Mission $mission): JsonResponse
|
||||
{
|
||||
return $this->successResponse($mission);
|
||||
}
|
||||
|
||||
public function update(UpdateRequest $request,Mission $mission): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($mission, $request) {
|
||||
$state = MissionStates::REQUEST_CREATED->value;
|
||||
$mission->update([
|
||||
'state_id' =>$state,
|
||||
'state_name' => MissionStates::name($state),
|
||||
'requested_machine_type' => $request->requested_machine_type,
|
||||
'requested_machine_numbers' => $request->requested_machine_numbers,
|
||||
'type' => $request->type,
|
||||
'start_date' => $request->start_date,
|
||||
'end_date' => $request->end_date,
|
||||
'request_date' => $request->request_date,
|
||||
'description' => $request->description,
|
||||
'start_point' => $request->start_point,
|
||||
'end_point' => $request->end_point,
|
||||
]);
|
||||
|
||||
$mission->rahdaran()->sync($request->rahdaran);
|
||||
});
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function destroy(Mission $mission): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($mission) {
|
||||
$mission->rahdaran()->detach();
|
||||
$mission->delete();
|
||||
});
|
||||
return $this->successResponse();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\Mission;
|
||||
|
||||
use App\Enums\MissionStates;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\Mission\TransportaionUnit\AllocateRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\Mission;
|
||||
use App\Services\Cartables\Mission\TransportationUnitService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TransportationUnitController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function index(Request $request, TransportationUnitService $transportationUnitService): JsonResponse
|
||||
{
|
||||
return response()->json($transportationUnitService->dataTable($request));
|
||||
}
|
||||
|
||||
public function allocate(AllocateRequest $request, Mission $mission): JsonResponse
|
||||
{
|
||||
$mission->machines()->attach($request->machines);
|
||||
|
||||
$state = MissionStates::PENDING_CONFIRMATION->value;
|
||||
$mission->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => MissionStates::name($state),
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function deallocate(Mission $mission): JsonResponse
|
||||
{
|
||||
$state = MissionStates::REJECT_BY_TRANSPORTATION->value;
|
||||
|
||||
$mission->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => MissionStates::name($state),
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ use App\Http\Requests\V3\SafetyAndPrivacy\UpdateRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\InfoItem;
|
||||
use App\Models\SafetyAndPrivacy;
|
||||
use App\Services\Cartables\SafetyAndPrivacyTableService;
|
||||
use App\Services\Cartables\SafetyAndPrivacy\OperatorService;
|
||||
use App\Services\NominatimService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -34,18 +34,18 @@ class OperatorController extends Controller
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function index(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse
|
||||
public function index(Request $request, OperatorService $operatorService): JsonResponse
|
||||
{
|
||||
return response()->json($safetyAndPrivacyTableService->operatorDatatable($request));
|
||||
return response()->json($operatorService->datatable($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function excelReport(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): BinaryFileResponse
|
||||
public function excelReport(Request $request, OperatorService $operatorService): BinaryFileResponse
|
||||
{
|
||||
$name = 'گزارش از نگهداری حریم راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||
$data = $safetyAndPrivacyTableService->operatorDatatable($request);
|
||||
$data = $operatorService->datatable($request);
|
||||
return Excel::download(new OperatorCartableReport($data['data']), $name);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\EdarateShahri;
|
||||
use App\Models\Province;
|
||||
use App\Services\Cartables\SafetyAndPrivacy\OperatorService;
|
||||
use App\Services\Cartables\SafetyAndPrivacyTableService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -18,34 +19,34 @@ class OperatorReportController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function countryActivity(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse
|
||||
public function countryActivity(Request $request, OperatorService $operatorService): JsonResponse
|
||||
{
|
||||
$data = $safetyAndPrivacyTableService->countryActivity($request);
|
||||
$data = $operatorService->countryActivity($request);
|
||||
return $this->successResponse([
|
||||
'activities' => $data,
|
||||
'provinces' => Province::all(['id', 'name_fa'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function provinceActivity(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse
|
||||
public function provinceActivity(Request $request, OperatorService $operatorService): JsonResponse
|
||||
{
|
||||
$data = $safetyAndPrivacyTableService->provinceActivity($request);
|
||||
$data = $operatorService->provinceActivity($request);
|
||||
return $this->successResponse([
|
||||
'activities' => $data,
|
||||
'edarateShahri' => EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']),
|
||||
]);
|
||||
}
|
||||
|
||||
public function countryExcelActivity(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): BinaryFileResponse
|
||||
public function countryExcelActivity(Request $request, OperatorService $operatorService): BinaryFileResponse
|
||||
{
|
||||
$data = $safetyAndPrivacyTableService->countryActivity($request);
|
||||
$data = $operatorService->countryActivity($request);
|
||||
$name = 'گزارش از نگهداری حریم راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||
return Excel::download(new CountryActivityReport($data), $name);
|
||||
}
|
||||
|
||||
public function provinceExcelActivity(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): BinaryFileResponse
|
||||
public function provinceExcelActivity(Request $request, OperatorService $operatorService): BinaryFileResponse
|
||||
{
|
||||
$data = $safetyAndPrivacyTableService->provinceActivity($request);
|
||||
$data = $operatorService->provinceActivity($request);
|
||||
$name = 'گزارش از نگهداری حریم راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||
return Excel::download(new ProvinceActivityReport($data, $request), $name);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\SafetyAndPrivacy\RejectRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\SafetyAndPrivacy;
|
||||
use App\Services\Cartables\SafetyAndPrivacy\SupervisorService;
|
||||
use App\Services\Cartables\SafetyAndPrivacyTableService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -22,18 +23,18 @@ class SupervisorController extends Controller
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function index(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse
|
||||
public function index(Request $request, SupervisorService $supervisorService): JsonResponse
|
||||
{
|
||||
return response()->json($safetyAndPrivacyTableService->supervisorDataTable($request));
|
||||
return response()->json($supervisorService->dataTable($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function excelReport(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): BinaryFileResponse
|
||||
public function excelReport(Request $request, SupervisorService $supervisorService): BinaryFileResponse
|
||||
{
|
||||
$name = 'گزارش از نگهداری حریم راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||
$data = $safetyAndPrivacyTableService->supervisorDataTable($request);
|
||||
$data = $supervisorService->dataTable($request);
|
||||
return Excel::download(new SupervisorCartableReport($data['data']), $name);
|
||||
}
|
||||
|
||||
|
||||
38
app/Http/Requests/V3/Mission/RequestPortal/StoreRequest.php
Normal file
38
app/Http/Requests/V3/Mission/RequestPortal/StoreRequest.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Mission\RequestPortal;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'rahdaran' => 'required|array',
|
||||
'rahdaran.*' => 'exists:rahdaran,id',
|
||||
'requested_machine_type' => 'required|string|max:255',
|
||||
'requested_machine_numbers'=> 'required|integer|max:255',
|
||||
'type' => 'required|string|max:50',
|
||||
'start_date' => 'required|date',
|
||||
'end_date' => 'required|date',
|
||||
'request_date' => 'required|date',
|
||||
'description' => 'string',
|
||||
'start_point' => 'required|string',
|
||||
'end_point' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
38
app/Http/Requests/V3/Mission/RequestPortal/UpdateRequest.php
Normal file
38
app/Http/Requests/V3/Mission/RequestPortal/UpdateRequest.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Mission\RequestPortal;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return ($this->route('mission'))->user_id === auth()->id();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'rahdaran' => 'required|array',
|
||||
'rahdaran.*' => 'exists:rahdaran,id',
|
||||
'requested_machine_type' => 'required|string|max:255',
|
||||
'requested_machine_numbers'=> 'required|integer|max:255',
|
||||
'type' => 'required|string|max:50',
|
||||
'start_date' => 'required|date',
|
||||
'end_date' => 'required|date',
|
||||
'request_date' => 'required|date',
|
||||
'description' => 'string',
|
||||
'start_point' => 'required|string',
|
||||
'end_point' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Mission\TransportaionUnit;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class AllocateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->mission->edare_shahri_id == auth()->user()->edarate_shahri_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'machines' => 'required|array',
|
||||
'machines.*' => 'required|integer|exists:cmms_machines,id',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -26,4 +26,24 @@ class Mission extends Model
|
||||
{
|
||||
return $this->morphedByMany(RoadObserved::class, 'missionable');
|
||||
}
|
||||
|
||||
public function machines(): MorphToMany
|
||||
{
|
||||
return $this->morphToMany(CMMSMachine::class,
|
||||
'machinable',
|
||||
'machinables',
|
||||
'machinable_id',
|
||||
'machine_id'
|
||||
);
|
||||
}
|
||||
|
||||
public function rahdaran(): MorphToMany
|
||||
{
|
||||
return $this->morphToMany(Rahdaran::class,
|
||||
'rahdarable',
|
||||
'rahdarables',
|
||||
'rahdarable_id',
|
||||
'rahdar_id',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
34
app/Services/Cartables/Mission/RequestPortalService.php
Normal file
34
app/Services/Cartables/Mission/RequestPortalService.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Cartables\Mission;
|
||||
|
||||
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\Mission;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RequestPortalService
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function datatable(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$query = Mission::query();
|
||||
|
||||
if ($user->hasPermissionTo('mission-manage-city')) {
|
||||
$query->where('edarate_shahri_id', '=', $user->edarate_shahri_id);
|
||||
}
|
||||
elseif ($user->hasPermissionTo('mission-manage-province')) {
|
||||
$query->where('province_id', '=', $user->province_id);
|
||||
}
|
||||
return DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*']
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
33
app/Services/Cartables/Mission/TransportationUnitService.php
Normal file
33
app/Services/Cartables/Mission/TransportationUnitService.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Cartables\Mission;
|
||||
|
||||
use App\Enums\MissionStates;
|
||||
use App\Exceptions\ProhibitedAction;
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Models\Mission;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TransportationUnitService
|
||||
{
|
||||
public function dataTable(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
$fields = [
|
||||
'id', '', '', '', ''
|
||||
];
|
||||
|
||||
// throw_if(is_null($user->edarate_shahri_id), new ProhibitedAction('اداره ای برای شما در سامانه ثبت نشده است!'));
|
||||
|
||||
$query = Mission::query()->where('state_id', '=', MissionStates::REQUEST_CREATED->value);
|
||||
|
||||
return DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
allowedSelects: $fields
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Cartables;
|
||||
namespace App\Services\Cartables\SafetyAndPrivacy;
|
||||
|
||||
use App\Exceptions\ProhibitedAction;
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\Province;
|
||||
use App\Models\SafetyAndPrivacy;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Throwable;
|
||||
|
||||
class SafetyAndPrivacyTableService
|
||||
class OperatorService
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function operatorDataTable(Request $request)
|
||||
public function dataTable(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
@@ -41,37 +32,6 @@ class SafetyAndPrivacyTableService
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function supervisorDataTable(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
$fields = [
|
||||
'id','lat','lon', 'recognize_picture','action_picture','created_at','status', 'final_description', 'province_fa',
|
||||
'info_fa', 'activity_date_time', 'action_picture_document_upload_date', 'judiciary_document_upload_date', 'edare_shahri_name',
|
||||
'step_fa', 'axis_type_id', 'axis_type_name', 'action_date', 'is_finished', 'status_fa', 'supervisor_description', 'operator_description'
|
||||
];
|
||||
|
||||
$query = SafetyAndPrivacy::query();
|
||||
|
||||
if ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-province'))
|
||||
{
|
||||
throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!'));
|
||||
|
||||
$query = $query->where('province_id', '=', $user->province_id);
|
||||
}
|
||||
|
||||
return DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
allowedSelects: $fields
|
||||
);
|
||||
}
|
||||
|
||||
public function countryActivity(Request $request): array
|
||||
{
|
||||
$activities = [];
|
||||
@@ -186,4 +146,4 @@ class SafetyAndPrivacyTableService
|
||||
|
||||
return array_values($activities);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Cartables\SafetyAndPrivacy;
|
||||
|
||||
use App\Exceptions\ProhibitedAction;
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Models\SafetyAndPrivacy;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SupervisorService
|
||||
{
|
||||
public function dataTable(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
$fields = [
|
||||
'id','lat','lon', 'recognize_picture','action_picture','created_at','status', 'final_description', 'province_fa',
|
||||
'info_fa', 'activity_date_time', 'action_picture_document_upload_date', 'judiciary_document_upload_date', 'edare_shahri_name',
|
||||
'step_fa', 'axis_type_id', 'axis_type_name', 'action_date', 'is_finished', 'status_fa', 'supervisor_description', 'operator_description'
|
||||
];
|
||||
|
||||
$query = SafetyAndPrivacy::query();
|
||||
|
||||
if ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-province'))
|
||||
{
|
||||
throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!'));
|
||||
|
||||
$query = $query->where('province_id', '=', $user->province_id);
|
||||
}
|
||||
|
||||
return DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
allowedSelects: $fields
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -13,13 +13,17 @@ return new class extends Migration
|
||||
{
|
||||
Schema::create('missions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained('users');
|
||||
$table->foreignId('machine_id')->nullable()->constrained('cmms_machines');
|
||||
$table->foreignId('rahdar_id')->constrained('rahdaran');
|
||||
$table->foreignId('state_id')->constrained('mission_states');
|
||||
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
|
||||
$table->foreignId('machine_id')->nullable()->constrained('cmms_machines')->noActionOnDelete();
|
||||
$table->foreignId('rahdar_id')->constrained('rahdaran')->noActionOnDelete();
|
||||
$table->foreignId('state_id')->constrained('mission_states')->noActionOnDelete();
|
||||
$table->string('state_name');
|
||||
$table->foreignId('province_id')->constrained('provinces')->noActionOnDelete();
|
||||
$table->string('province_name');
|
||||
$table->foreignId('edare_shahri_id')->constrained('edarate_shahri')->noActionOnDelete();
|
||||
$table->string('edare_shahri_name');
|
||||
$table->string('requested_machine_type');
|
||||
$table->string('requested_machine_numbers');
|
||||
$table->integer('requested_machine_numbers');
|
||||
$table->string('type');
|
||||
$table->dateTime('start_date');
|
||||
$table->dateTime('end_date');
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Http\Controllers\V3\Dashboard\Azmayesh\AzmayeshController;
|
||||
use App\Http\Controllers\V3\Dashboard\Azmayesh\AzmayeshSampleController;
|
||||
use App\Http\Controllers\V3\Dashboard\Azmayesh\AzmayeshTypeController;
|
||||
use App\Http\Controllers\V3\Dashboard\ItemsManagementController;
|
||||
use App\Http\Controllers\V3\Dashboard\Mission\RequestPortalController;
|
||||
use App\Http\Controllers\V3\Dashboard\ObservedItemController;
|
||||
use App\Http\Controllers\V3\Dashboard\AccidentReceiptController;
|
||||
use App\Http\Controllers\V3\Dashboard\OtpManagementController;
|
||||
@@ -424,3 +425,13 @@ Route::prefix('road_maintenance_station')
|
||||
Route::post('/{rahdariPoint}', 'update')->name('update')->middleware('permission:edit-tollhouse|edit-tollhouse-province');
|
||||
Route::delete('/{rahdariPoint}', 'destroy')->name('destroy')->middleware('permission:delete-tollhouse|delete-tollhouse-province');
|
||||
});
|
||||
Route::prefix('missions')
|
||||
->name('missions.')
|
||||
->controller(RequestPortalController::class)
|
||||
->group(function () {
|
||||
Route::get('/', 'index')->name('index');
|
||||
Route::post('/', 'store')->name('store');
|
||||
Route::get('/{mission}', 'show')->name('show');
|
||||
Route::post('/{mission}', 'update')->name('update');
|
||||
Route::delete('/{mission}', 'destroy')->name('destroy');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user