create map for rahdari point

This commit is contained in:
2025-04-14 10:47:11 +03:30
parent 822730afb1
commit b25ce4bfe2
4 changed files with 40 additions and 17 deletions

View File

@@ -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'],
));
}
}

View File

@@ -3,6 +3,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphTo;
class PointFile extends Model
{
@@ -25,13 +26,15 @@ class PointFile extends Model
* @var array
*/
protected $fillable = [
'path'
'path',
'point_fileable_id',
'point_fileable_type',
];
/**
* Get the owning point_fileable model.
*/
public function point_fileable()
public function point_fileable(): MorphTo
{
return $this->morphTo();
}

View File

@@ -21,18 +21,18 @@
<table>
<thead>
<tr>
<th colspan="9"
<th colspan="10"
style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;">
تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
</th>
</tr>
<tr>
<th colspan="9"
<th colspan="10"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
</th>
</tr>
<tr>
<th colspan="9"
<th colspan="10"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
گزارش فعالیت های نگهداری حریم راه
</th>
@@ -72,7 +72,7 @@
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
تاریخ ثبت اقدام
تاریخ اقدام
</th>
<th rowspan="1"
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
@@ -97,7 +97,7 @@
</td>
<td style="border: 1px solid black;text-align: center;">
{{ $item['action_picture_document_upload_date'] ? verta($item['action_picture_document_upload_date'])->format('Y/n/j H:i:s') : '-' }}
{{ $item['action_picture_document_upload_date'] ? verta($item['action_date'])->format('Y/n/j H:i:s') : '-' }}
</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['step_fa'] ?? '-' }}</td>

View File

@@ -394,6 +394,8 @@ Route::prefix('road_maintenance_station')
->group(function () {
Route::get('/', 'index')->name('index')->middleware('permission:show-tollhouse|show-tollhouse-province');
Route::post('/', 'store')->name('store');
Route::post('/map', 'map')->name('map');
Route::post('/images/{rahdariPoint}', 'images')->name('images');
Route::get('/{rahdariPoint}', 'show')->name('show')->middleware('permission:show-tollhouse|show-tollhouse-province');
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');