add confirm and reject api
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\V3\Dashboard;
|
||||
|
||||
use App\Enums\AxisTypes;
|
||||
use App\Enums\SafetyAndPrivacyStatus;
|
||||
use App\Exports\V3\SafetyAndPrivacy\CartableReport;
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Facades\File\FileFacade;
|
||||
@@ -18,10 +19,8 @@ use App\Services\Cartables\SafetyAndPrivacyTableService;
|
||||
use App\Services\NominatimService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Throwable;
|
||||
@@ -33,9 +32,9 @@ class SafetyAndPrivacyController extends Controller
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function index(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse
|
||||
public function operatorIndex(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse
|
||||
{
|
||||
return response()->json($safetyAndPrivacyTableService->datatable($request));
|
||||
return response()->json($safetyAndPrivacyTableService->operatorDatatable($request));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,7 +43,7 @@ class SafetyAndPrivacyController extends Controller
|
||||
public function excelReport(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): BinaryFileResponse
|
||||
{
|
||||
$name = 'گزارش از نگهداری حریم راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||
$data = $safetyAndPrivacyTableService->datatable($request);
|
||||
$data = $safetyAndPrivacyTableService->operatorDatatable($request);
|
||||
return Excel::download(new CartableReport($data['data']), $name);
|
||||
}
|
||||
|
||||
@@ -78,7 +77,8 @@ class SafetyAndPrivacyController extends Controller
|
||||
'axis_type_id' => $request->axis_type_id,
|
||||
'axis_type_name' => AxisTypes::name($request->axis_type_id),
|
||||
'step' => 1,
|
||||
'step_fa' => 'گام اول (شناسایی)'
|
||||
'step_fa' => 'گام اول (شناسایی)',
|
||||
'is_finished' => false
|
||||
]);
|
||||
|
||||
$safety_and_privacy->recognize_picture = $request->has('recognize_picture') ?
|
||||
@@ -197,4 +197,39 @@ class SafetyAndPrivacyController extends Controller
|
||||
allowedSelects: ['id', 'lat', 'lon', 'step']
|
||||
));
|
||||
}
|
||||
|
||||
public function confirm(Request $request, SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
|
||||
{
|
||||
$safetyAndPrivacy->update([
|
||||
'status' => SafetyAndPrivacyStatus::CONFIRM->value,
|
||||
'supervisor_description' => $request->supervisor_description
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function reject(Request $request, SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
|
||||
{
|
||||
$safetyAndPrivacy->update([
|
||||
'status' => SafetyAndPrivacyStatus::REJECT->value,
|
||||
'supervisor_description' => $request->supervisor_description
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function finish(Request $request, SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
|
||||
{
|
||||
$safetyAndPrivacy->update([
|
||||
'is_finished' => $request->is_finished,
|
||||
'final_description' => $request->final_description
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function supervisorIndex(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse
|
||||
{
|
||||
return response()->json($safetyAndPrivacyTableService->supervisorDataTable($request));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,8 @@ class SafetyAndPrivacy extends Model
|
||||
'action_date',
|
||||
'status',
|
||||
'final_description',
|
||||
'is_finished'
|
||||
'is_finished',
|
||||
'supervisor_description'
|
||||
];
|
||||
|
||||
public $table = "safety_and_privacy";
|
||||
|
||||
@@ -14,6 +14,7 @@ return new class extends Migration
|
||||
Schema::table('safety_and_privacy', function (Blueprint $table) {
|
||||
$table->boolean('is_finished')->nullable();
|
||||
$table->integer('status')->nullable();
|
||||
$table->string('supervisor_description')->nullable();
|
||||
$table->string('final_description')->nullable();
|
||||
});
|
||||
}
|
||||
@@ -24,7 +25,7 @@ return new class extends Migration
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('safety_and_privacy', function (Blueprint $table) {
|
||||
$table->dropColumn(['status', 'final_description', 'is_finished']);
|
||||
$table->dropColumn(['status', 'final_description', 'is_finished', 'supervisor_description']);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -337,7 +337,7 @@ Route::prefix('safety_and_privacy')
|
||||
->name('SafetyAndPrivacy.')
|
||||
->controller(SafetyAndPrivacyController::class)
|
||||
->group(function () {
|
||||
Route::get('/', 'index')->name('index')->middleware('permission:show-safety-and-privacy-operator-cartable|show-safety-and-privacy-operator-cartable-province|show-safety-and-privacy-operator-cartable-edarate-shahri');
|
||||
Route::get('/', 'operatorIndex')->name('operatorIndex')->middleware('permission:show-safety-and-privacy-operator-cartable|show-safety-and-privacy-operator-cartable-province|show-safety-and-privacy-operator-cartable-edarate-shahri');
|
||||
Route::get('/excel_report', 'excelReport')->name('excelReport')->middleware('permission:show-safety-and-privacy-operator-cartable|show-safety-and-privacy-operator-cartable-province|show-safety-and-privacy-operator-cartable-edarate-shahri');
|
||||
Route::post('/first_step_store', 'firstStepStore')->name('firstStepStore')
|
||||
->middleware(['validate-store-access', 'permission:add-safety-and-privacy']);
|
||||
|
||||
Reference in New Issue
Block a user