create map for rahdari point
This commit is contained in:
@@ -36,7 +36,7 @@ class RoadMaintenanceStationController extends Controller
|
||||
$status = $request->status;
|
||||
$type = $request->type;
|
||||
|
||||
$query = RahdariPoint::with('files')
|
||||
$query = RahdariPoint::query()
|
||||
->when($status, fn ($query, $status) => $query->where('status', $status))
|
||||
->when($type, fn ($query, $type) => $query->where('type', $type))
|
||||
->when($province, fn($query, $province) => $query->where('province_id', $province));
|
||||
@@ -113,11 +113,11 @@ class RoadMaintenanceStationController extends Controller
|
||||
]);
|
||||
|
||||
$uploadPaths = [
|
||||
'overview_files_1' => 'road_stations',
|
||||
'overview_files_2' => 'road_stations',
|
||||
'overview_files_3' => 'road_stations',
|
||||
'overview_files_4' => 'road_stations',
|
||||
'overview_files_5' => 'road_stations',
|
||||
'overview_files_1' => "road_stations/{$station->id}",
|
||||
'overview_files_2' => "road_stations/{$station->id}",
|
||||
'overview_files_3' => "road_stations/{$station->id}",
|
||||
'overview_files_4' => "road_stations/{$station->id}",
|
||||
'overview_files_5' => "road_stations/{$station->id}",
|
||||
];
|
||||
|
||||
foreach ($uploadPaths as $field => $path) {
|
||||
@@ -136,7 +136,7 @@ class RoadMaintenanceStationController extends Controller
|
||||
*/
|
||||
public function show(RahdariPoint $rahdariPoint): JsonResponse
|
||||
{
|
||||
return $this->successResponse($rahdariPoint->load('files'));
|
||||
return $this->successResponse($rahdariPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,13 +201,13 @@ class RoadMaintenanceStationController extends Controller
|
||||
if ($request->hasFile($field)) {
|
||||
$existingFile = $rahdariPoint->files->get($index);
|
||||
|
||||
$newPath = FileFacade::save($request->field, 'rahdari_points/overview');
|
||||
$path = FileFacade::save($request->$field, "road_stations/{$rahdariPoint->id}");
|
||||
|
||||
if ($existingFile) {
|
||||
FileFacade::delete($existingFile->path);
|
||||
$existingFile->update(['path' => $newPath]);
|
||||
$existingFile->update(['path' => $path]);
|
||||
} else {
|
||||
$rahdariPoint->files()->create(['path' => $newPath]);
|
||||
$rahdariPoint->files()->create(['path' => $path]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -229,4 +229,22 @@ class RoadMaintenanceStationController extends Controller
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function images(RahdariPoint $rahdariPoint): JsonResponse
|
||||
{
|
||||
return $this->successResponse($rahdariPoint->files()->get(['path']));
|
||||
}
|
||||
|
||||
public function map(Request $request): JsonResponse
|
||||
{
|
||||
auth()->user()->addActivityComplete(1023);
|
||||
|
||||
return response()->json(DataTableFacade::run(
|
||||
RahdariPoint::query(),
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
allowedSelects: ['id', 'lat', 'lng', 'status', 'type'],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user