From 8d138b83390d6a066862b2fcd8213f860ed7750d Mon Sep 17 00:00:00 2001 From: amirghasempoor Date: Tue, 15 Apr 2025 10:45:47 +0330 Subject: [PATCH 01/10] add group by feature to datatable --- app/Facades/DataTable/DataTable.php | 9 +- .../Dashboard/SafetyAndPrivacyController.php | 7 + app/Models/RahdariPointHistory.php | 5 + .../SafetyAndPrivacyTableService.php | 177 +++++------------- app/Services/DataTable/DataTableInput.php | 6 + app/Services/DataTable/DataTableService.php | 16 +- 6 files changed, 91 insertions(+), 129 deletions(-) diff --git a/app/Facades/DataTable/DataTable.php b/app/Facades/DataTable/DataTable.php index ae637a86..86d25fe6 100644 --- a/app/Facades/DataTable/DataTable.php +++ b/app/Facades/DataTable/DataTable.php @@ -28,7 +28,8 @@ class DataTable array $allowedFilters = [], array $allowedRelations = [], array $allowedSortings = [], - array $allowedSelects = [] + array $allowedSelects = [], + ?array $allowedGroupBy = null ): array { @@ -43,7 +44,8 @@ class DataTable $sorting, $rels, $allowedFilters, - $allowedSortings + $allowedSortings, + $allowedGroupBy ); $query = $this->makeQueryFromModel($mixed); @@ -52,7 +54,8 @@ class DataTable ->setAllowedFilters($allowedFilters) ->setAllowedRelations($allowedRelations) ->setAllowedSortings($allowedSortings) - ->setAllowedSelects($allowedSelects); + ->setAllowedSelects($allowedSelects) + ->setAllowedGroupBy($allowedGroupBy); return $dataTableService->getData(); } diff --git a/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacyController.php b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacyController.php index 5741f4ff..693a1864 100644 --- a/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacyController.php +++ b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacyController.php @@ -24,16 +24,23 @@ use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Validator; use Maatwebsite\Excel\Facades\Excel; use Symfony\Component\HttpFoundation\BinaryFileResponse; +use Throwable; class SafetyAndPrivacyController extends Controller { use ApiResponse; + /** + * @throws Throwable + */ public function index(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse { return response()->json($safetyAndPrivacyTableService->datatable($request)); } + /** + * @throws Throwable + */ public function excelReport(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): BinaryFileResponse { $name = 'گزارش از نگهداری حریم راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx'; diff --git a/app/Models/RahdariPointHistory.php b/app/Models/RahdariPointHistory.php index e8d2e9fd..c6d359bc 100644 --- a/app/Models/RahdariPointHistory.php +++ b/app/Models/RahdariPointHistory.php @@ -13,6 +13,11 @@ class RahdariPointHistory extends Model */ protected $fillable = [ 'user_id', + 'previous_province_id', + 'previous_province_name', + 'previous_city_id', + 'previous_city_name', + 'previous_name', 'previous_status', 'previous_type', 'previous_team_num', diff --git a/app/Services/Cartables/SafetyAndPrivacyTableService.php b/app/Services/Cartables/SafetyAndPrivacyTableService.php index 891999cc..304c3532 100644 --- a/app/Services/Cartables/SafetyAndPrivacyTableService.php +++ b/app/Services/Cartables/SafetyAndPrivacyTableService.php @@ -2,17 +2,22 @@ namespace App\Services\Cartables; +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 { use ApiResponse; + /** + * @throws Throwable + */ public function dataTable(Request $request, $loadRelations = false) { $user = auth()->user(); @@ -27,16 +32,12 @@ class SafetyAndPrivacyTableService $query = SafetyAndPrivacy::query()->select($fields); } elseif ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-province')) { - if (is_null($user->province_id)) { - return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!'); - } + throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!')); $query = SafetyAndPrivacy::query()->where('province_id', '=', $user->province_id)->select($fields); } elseif ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-edarate-shahri')) { - if (is_null($user->edarate_shahri_id)) { - return $this->errorResponse('اداره ای برای شما در سامانه ثبت نشده است!'); - } + throw_if(is_null($user->edarate_shahri_id), new ProhibitedAction('اداره ای برای شما در سامانه ثبت نشده است!')); $query = SafetyAndPrivacy::query()->where('edare_shahri_id', '=', $user->edarate_shahri_id); } @@ -51,74 +52,45 @@ class SafetyAndPrivacyTableService public function countryActivity(Request $request): array { - $fromDate = $request->from_date ? $request->from_date . ' 00:00:00' : now()->startOfDay()->toDateTimeString(); - $toDate = $request->date_to ? $request->date_to . ' 23:59:59' : now()->endOfDay()->toDateTimeString(); - $axisTypeId = $request->axis_type_id; - $activities = []; + $countryQuery = SafetyAndPrivacy::query()->selectRaw('COUNT(*) as qty,info_id, step'); - $country = SafetyAndPrivacy::query() - ->selectRaw('COUNT(*) as qty,info_id, step') - ->whereBetween('created_at', [$fromDate, $toDate]) - ->when($axisTypeId, function ($query) use ($axisTypeId) { - $query->where('axis_type_id', '=', $axisTypeId); - }) - ->groupBy('info_id', 'step') - ->get(); - -// $country = DB::select( -// "SELECT COUNT(*) as qty,info_id, step -// FROM safety_and_privacy where created_at BETWEEN '".$fromDate."' and '".$toDate."' -// GROUP BY info_id,step" -// ); + $country = DataTableFacade::run( + $countryQuery, + $request, + allowedFilters: ['*'], + allowedSortings: ['*'], + allowedGroupBy: ['info_id', 'step'] + ); $countryTotalSum = 0; $countryData = [ 'name_fa' => 'کشوری', 'province_id' => -1, 'sum' => 0, - '89' => [ - '1' => 0, - '2' => 0, - '3' => 0, - ], - '90' => [ - '1' => 0, - '2' => 0, - '3' => 0, - ], - '91' => [ - '1' => 0, - '2' => 0, - '3' => 0, - ], + '89' => ['1' => 0, '2' => 0, '3' => 0,], + '90' => ['1' => 0, '2' => 0, '3' => 0,], + '91' => ['1' => 0, '2' => 0, '3' => 0,], ]; foreach ($country as $key => $value) { $countryTotalSum += $value->qty; $countryData[$value->info_id][$value->step] = $value->qty; $countryData["sum"] = $countryTotalSum; } + $activities[] = (object) $countryData; + $provinceQuery = Province::query()->selectRaw('province_id, province_fa, COUNT(*) as qty,info_id, step'); + $provinces = DataTableFacade::run( + $provinceQuery, + $request, + allowedFilters: ['*'], + allowedSortings: ['*'], + allowedGroupBy: ['info_id', 'step', 'province_id', 'province_fa'] + ); - $provinces = SafetyAndPrivacy::query() - ->selectRaw('province_id, province_fa, COUNT(*) as qty,info_id, step') - ->whereBetween('created_at', [$fromDate, $toDate]) - ->when($axisTypeId, function ($query) use ($axisTypeId) { - $query->where('axis_type_id', '=', $axisTypeId); - }) - ->groupBy('info_id', 'step', 'province_id', 'province_fa') - ->get(); - -// $provinces = DB::select( -// "SELECT province_id, province_fa, COUNT(*) as qty,info_id, step -// FROM safety_and_privacy where created_at BETWEEN '".$fromDate."' and '".$toDate."' -// GROUP BY info_id,step,province_id,province_fa" -// ); - - foreach ($provinces as $value) { + foreach ($provinces as $value) + { $provinceId = $value->province_id; - - // Check if the province already exists in the activities array if (!isset($activities[$provinceId])) { $activities[$provinceId] = (object) [ 'province_id' => $provinceId, @@ -129,64 +101,33 @@ class SafetyAndPrivacyTableService '91' => ['1' => 0, '2' => 0, '3' => 0], ]; } - $activities[$provinceId]->{$value->info_id}[$value->step] = $value->qty; $activities[$provinceId]->sum += $value->qty; } - $activities = array_values($activities); - - return [ - 'activities' => $activities, - 'fromDate' => $fromDate, - 'toDate' => $toDate, - ]; + return array_values($activities); } public function provinceActivity(Request $request): array { - $fromDate = $request->from_date ? $request->from_date . ' 00:00:00' : now()->startOfDay()->toDateTimeString(); - $toDate = $request->date_to ? $request->date_to . ' 23:59:59' : now()->endOfDay()->toDateTimeString(); - $provinceId = $request->province_id; - $axisTypeId = $request->axis_type_id; $activities = []; - - $province = SafetyAndPrivacy::query() - ->selectRaw('COUNT(*) as qty,info_id, step') - ->where('province_id', '=', $provinceId) - ->whereBetween('created_at', [$fromDate, $toDate]) - ->when($axisTypeId, function ($query) use ($axisTypeId) { - $query->where('axis_type_id', '=', $axisTypeId); - }) - ->groupBy('info_id', 'step') - ->get(); - -// $province = DB::select(' -// SELECT COUNT(*) as qty,info_id, step -// FROM safety_and_privacy where province_id ='.$provinceId.' and created_at BETWEEN "'.$fromDate.'" and "'.$toDate.'" -// GROUP BY info_id,step -// '); + $provinceQuery = Province::query()->selectRaw('COUNT(*) as qty,info_id, step'); + $province = DataTableFacade::run( + $provinceQuery, + $request, + allowedFilters: ['*'], + allowedSortings: ['*'], + allowedGroupBy: ['info_id', 'step'] + ); $provinceTotalSum = 0; $provinceData = [ 'name_fa' => 'استانی', 'edare_shahri_id' => -1, 'sum' => 0, - '89' => [ - '1' => 0, - '2' => 0, - '3' => 0, - ], - '90' => [ - '1' => 0, - '2' => 0, - '3' => 0, - ], - '91' => [ - '1' => 0, - '2' => 0, - '3' => 0, - ], + '89' => ['1' => 0, '2' => 0, '3' => 0,], + '90' => ['1' => 0, '2' => 0, '3' => 0,], + '91' => ['1' => 0, '2' => 0, '3' => 0,], ]; foreach ($province as $key => $value) { $provinceTotalSum += $value->qty; @@ -195,26 +136,18 @@ class SafetyAndPrivacyTableService } $activities[] = (object) $provinceData; - $cities = SafetyAndPrivacy::query() - ->selectRaw('edare_shahri_id, COUNT(*) as qty,info_id, step') - ->where('province_id', '=', $provinceId) - ->whereBetween('created_at', [$fromDate, $toDate]) - ->when($axisTypeId, function ($query) use ($axisTypeId) { - $query->where('axis_type_id', '=', $axisTypeId); - }) - ->groupBy('info_id', 'step', 'edare_shahri_id') - ->get(); + $citiesQuery = SafetyAndPrivacy::query()->selectRaw('edare_shahri_id, COUNT(*) as qty,info_id, step'); + $cities = DataTableFacade::run( + $citiesQuery, + $request, + allowedFilters: ['*'], + allowedSortings: ['*'], + allowedGroupBy: ['info_id', 'step', 'edare_shahri_id'] + ); -// $cities = DB::select(' -// SELECT edare_shahri_id, COUNT(*) as qty,info_id, step -// FROM safety_and_privacy where province_id ='.$provinceId.' and created_at BETWEEN "'.$fromDate.'" and "'.$toDate.'" -// GROUP BY info_id,step,edare_shahri_id -// '); - - foreach ($cities as $value) { + foreach ($cities as $value) + { $cityId = $value->edare_shahri_id; - - // Initialize data for each unique city if (!isset($activities[$cityId])) { $activities[$cityId] = (object) [ 'edare_shahri_id' => $cityId, @@ -229,12 +162,6 @@ class SafetyAndPrivacyTableService $activities[$cityId]->sum += $value->qty; } - $activities = array_values($activities); - - return [ - 'activities' => $activities, - 'fromDate' => $fromDate, - 'toDate' => $toDate, - ]; + return array_values($activities); } } diff --git a/app/Services/DataTable/DataTableInput.php b/app/Services/DataTable/DataTableInput.php index 8464e878..1bbe5200 100644 --- a/app/Services/DataTable/DataTableInput.php +++ b/app/Services/DataTable/DataTableInput.php @@ -22,6 +22,7 @@ class DataTableInput private array $rels, private array $allowedFilters, private array $allowedSortings, + private ?array $GroupBy, ) { } @@ -74,4 +75,9 @@ class DataTableInput { return $this->rels; } + + public function getGroupBy(): ?array + { + return $this->GroupBy; + } } diff --git a/app/Services/DataTable/DataTableService.php b/app/Services/DataTable/DataTableService.php index 647f6e44..442f6e48 100644 --- a/app/Services/DataTable/DataTableService.php +++ b/app/Services/DataTable/DataTableService.php @@ -13,6 +13,7 @@ class DataTableService protected array $allowedRelations; protected array $allowedSortings; protected array $allowedSelects; + protected array $allowedGroupBy; private int $totalRowCount; public function __construct( @@ -46,6 +47,12 @@ class DataTableService return $this; } + public function setAllowedGroupBy(array $allowedGroupBy): DataTableService + { + $this->allowedGroupBy = $allowedGroupBy; + return $this; + } + /** * Handle 'getData' operations * @return array @@ -88,7 +95,9 @@ class DataTableService foreach ($sorting as $sort){ $query = (new ApplySort($query, $sort))->apply(); } - + + $query = $this->applyGroupBy($query, $this->allowedGroupBy); + return $query; } @@ -101,6 +110,11 @@ class DataTableService return $query; } + protected function applyGroupBy(Builder $query, array $groupBy): Builder + { + return empty($groupBy) ? $query : $query->groupBy($groupBy); + } + protected function includeRelationsInQuery(Builder $query, array $rels): Builder { if (!empty($rels)) { From b46bd53254e14b972b8d4f26b60b577d2746ebdf Mon Sep 17 00:00:00 2001 From: amirghasempoor Date: Tue, 15 Apr 2025 11:14:38 +0330 Subject: [PATCH 02/10] return the correct data values --- .../Reports/SafetyAndPrivacyReportController.php | 4 ++-- .../Cartables/SafetyAndPrivacyTableService.php | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/V3/Dashboard/Reports/SafetyAndPrivacyReportController.php b/app/Http/Controllers/V3/Dashboard/Reports/SafetyAndPrivacyReportController.php index cc3d5673..3346cdb7 100644 --- a/app/Http/Controllers/V3/Dashboard/Reports/SafetyAndPrivacyReportController.php +++ b/app/Http/Controllers/V3/Dashboard/Reports/SafetyAndPrivacyReportController.php @@ -22,7 +22,7 @@ class SafetyAndPrivacyReportController extends Controller { $data = $safetyAndPrivacyTableService->countryActivity($request); return $this->successResponse([ - 'activities' => $data['activities'], + 'activities' => $data, 'provinces' => Province::all(['id', 'name_fa']) ]); } @@ -31,7 +31,7 @@ class SafetyAndPrivacyReportController extends Controller { $data = $safetyAndPrivacyTableService->provinceActivity($request); return $this->successResponse([ - 'activities' => $data['activities'], + 'activities' => $data, 'edarateShahri' => EdarateShahri::query()->where('province_id', '=', $request->province_id)->get(['id', 'name_fa']), ]); } diff --git a/app/Services/Cartables/SafetyAndPrivacyTableService.php b/app/Services/Cartables/SafetyAndPrivacyTableService.php index 304c3532..33b8645a 100644 --- a/app/Services/Cartables/SafetyAndPrivacyTableService.php +++ b/app/Services/Cartables/SafetyAndPrivacyTableService.php @@ -72,14 +72,14 @@ class SafetyAndPrivacyTableService '90' => ['1' => 0, '2' => 0, '3' => 0,], '91' => ['1' => 0, '2' => 0, '3' => 0,], ]; - foreach ($country as $key => $value) { + foreach ($country['data'] as $key => $value) { $countryTotalSum += $value->qty; $countryData[$value->info_id][$value->step] = $value->qty; $countryData["sum"] = $countryTotalSum; } $activities[] = (object) $countryData; - $provinceQuery = Province::query()->selectRaw('province_id, province_fa, COUNT(*) as qty,info_id, step'); + $provinceQuery = SafetyAndPrivacy::query()->selectRaw('province_id, province_fa, COUNT(*) as qty,info_id, step'); $provinces = DataTableFacade::run( $provinceQuery, $request, @@ -88,7 +88,7 @@ class SafetyAndPrivacyTableService allowedGroupBy: ['info_id', 'step', 'province_id', 'province_fa'] ); - foreach ($provinces as $value) + foreach ($provinces['data'] as $value) { $provinceId = $value->province_id; if (!isset($activities[$provinceId])) { @@ -129,7 +129,7 @@ class SafetyAndPrivacyTableService '90' => ['1' => 0, '2' => 0, '3' => 0,], '91' => ['1' => 0, '2' => 0, '3' => 0,], ]; - foreach ($province as $key => $value) { + foreach ($province['data'] as $key => $value) { $provinceTotalSum += $value->qty; $provinceData["sum"] = $provinceTotalSum; $provinceData[$value->info_id][$value->step] = $value->qty; @@ -145,7 +145,7 @@ class SafetyAndPrivacyTableService allowedGroupBy: ['info_id', 'step', 'edare_shahri_id'] ); - foreach ($cities as $value) + foreach ($cities['data'] as $value) { $cityId = $value->edare_shahri_id; if (!isset($activities[$cityId])) { From ee933a3f917317d7e9e3901e0537128e0e5e0d44 Mon Sep 17 00:00:00 2001 From: amirghasempoor Date: Tue, 15 Apr 2025 15:50:14 +0330 Subject: [PATCH 03/10] order image files --- app/Facades/DataTable/DataTable.php | 2 +- .../V3/Dashboard/RoadMaintenanceStationController.php | 2 +- app/Services/Cartables/SafetyAndPrivacyTableService.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Facades/DataTable/DataTable.php b/app/Facades/DataTable/DataTable.php index 86d25fe6..63699505 100644 --- a/app/Facades/DataTable/DataTable.php +++ b/app/Facades/DataTable/DataTable.php @@ -29,7 +29,7 @@ class DataTable array $allowedRelations = [], array $allowedSortings = [], array $allowedSelects = [], - ?array $allowedGroupBy = null + array $allowedGroupBy = [] ): array { diff --git a/app/Http/Controllers/V3/Dashboard/RoadMaintenanceStationController.php b/app/Http/Controllers/V3/Dashboard/RoadMaintenanceStationController.php index 3dd07a5a..dc14f995 100644 --- a/app/Http/Controllers/V3/Dashboard/RoadMaintenanceStationController.php +++ b/app/Http/Controllers/V3/Dashboard/RoadMaintenanceStationController.php @@ -242,7 +242,7 @@ class RoadMaintenanceStationController extends Controller public function images(RahdariPoint $rahdariPoint): JsonResponse { - return $this->successResponse($rahdariPoint->files()->get(['path'])); + return $this->successResponse($rahdariPoint->files()->orderBy('id')->get(['path'])); } public function map(Request $request): JsonResponse diff --git a/app/Services/Cartables/SafetyAndPrivacyTableService.php b/app/Services/Cartables/SafetyAndPrivacyTableService.php index 33b8645a..afe8c30a 100644 --- a/app/Services/Cartables/SafetyAndPrivacyTableService.php +++ b/app/Services/Cartables/SafetyAndPrivacyTableService.php @@ -111,7 +111,7 @@ class SafetyAndPrivacyTableService public function provinceActivity(Request $request): array { $activities = []; - $provinceQuery = Province::query()->selectRaw('COUNT(*) as qty,info_id, step'); + $provinceQuery = SafetyAndPrivacy::query()->selectRaw('COUNT(*) as qty,info_id, step'); $province = DataTableFacade::run( $provinceQuery, $request, From 613a8f0bd815955141803abed62c8f5bcbe7354a Mon Sep 17 00:00:00 2001 From: amirghasempoor Date: Tue, 15 Apr 2025 16:08:16 +0330 Subject: [PATCH 04/10] refactor blade files --- app/Exports/V3/SafetyAndPrivacy/CountryActivityReport.php | 8 +++----- .../V3/SafetyAndPrivacy/ProvinceActivityReport.php | 6 +++--- .../SafetyAndPrivacy/CountryActivityReport.blade.php | 5 ----- .../SafetyAndPrivacy/ProvinceActivityReport.blade.php | 7 +------ 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/app/Exports/V3/SafetyAndPrivacy/CountryActivityReport.php b/app/Exports/V3/SafetyAndPrivacy/CountryActivityReport.php index b6e6ccb2..68e1b99a 100644 --- a/app/Exports/V3/SafetyAndPrivacy/CountryActivityReport.php +++ b/app/Exports/V3/SafetyAndPrivacy/CountryActivityReport.php @@ -19,13 +19,13 @@ class CountryActivityReport implements FromView, WithEvents, ShouldAutoSize, Wit public function view(): View { $data = $this->data; - $existedProvinces = array_keys($data['activities']); + $existedProvinces = array_keys($data); foreach (\App\Models\Province::all() as $value) { $provinceId = $value->id; if (!array_key_exists($provinceId, $existedProvinces)) { - $data['activities'][] = (object) [ + $data[] = (object) [ 'province_id' => $provinceId, 'name_fa' => $value->name_fa, 'sum' => 0, @@ -37,9 +37,7 @@ class CountryActivityReport implements FromView, WithEvents, ShouldAutoSize, Wit } return view('v3.Reports.SafetyAndPrivacy.CountryActivityReport', [ - 'data' => $data['activities'], - 'fromDate' => $data['fromDate'], - 'toDate' => $data['toDate'], + 'data' => $data, ]); } diff --git a/app/Exports/V3/SafetyAndPrivacy/ProvinceActivityReport.php b/app/Exports/V3/SafetyAndPrivacy/ProvinceActivityReport.php index 399b5bca..8e839d90 100644 --- a/app/Exports/V3/SafetyAndPrivacy/ProvinceActivityReport.php +++ b/app/Exports/V3/SafetyAndPrivacy/ProvinceActivityReport.php @@ -21,14 +21,14 @@ class ProvinceActivityReport implements FromView, WithEvents, ShouldAutoSize, Wi public function view(): View { $data = $this->data; - $existedCities = array_keys($data['activities']); + $existedCities = array_keys($data); $edarat = EdarateShahri::query()->where('province_id', '=', $this->request->province_id)->get(['id', 'name_fa']); foreach ($edarat as $value) { $edareId = $value->id; if (!array_key_exists($edareId, $existedCities)) { - $data['activities'][] = (object) [ + $data[] = (object) [ 'edare_shahri_id' => $edareId, 'name_fa' => $value->name_fa, 'sum' => 0, @@ -40,7 +40,7 @@ class ProvinceActivityReport implements FromView, WithEvents, ShouldAutoSize, Wi } return view('v3.Reports.SafetyAndPrivacy.ProvinceActivityReport', [ - 'data' => $data['activities'], + 'data' => $data, 'fromDate' => $data['fromDate'], 'toDate' => $data['toDate'], ]); diff --git a/resources/views/v3/Reports/SafetyAndPrivacy/CountryActivityReport.blade.php b/resources/views/v3/Reports/SafetyAndPrivacy/CountryActivityReport.blade.php index f7c5bd53..72009c19 100644 --- a/resources/views/v3/Reports/SafetyAndPrivacy/CountryActivityReport.blade.php +++ b/resources/views/v3/Reports/SafetyAndPrivacy/CountryActivityReport.blade.php @@ -29,11 +29,6 @@ گزارش نگهداری حریم راه از تاریخ - {{ verta($fromDate)->format('Y/n/j') }} - تا - تاریخ - {{ verta($toDate)->format('Y/n/j') }} - diff --git a/resources/views/v3/Reports/SafetyAndPrivacy/ProvinceActivityReport.blade.php b/resources/views/v3/Reports/SafetyAndPrivacy/ProvinceActivityReport.blade.php index 7e156b78..b5db906f 100644 --- a/resources/views/v3/Reports/SafetyAndPrivacy/ProvinceActivityReport.blade.php +++ b/resources/views/v3/Reports/SafetyAndPrivacy/ProvinceActivityReport.blade.php @@ -27,13 +27,8 @@ + style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;"> گزارش نگهداری حریم راه از تاریخ - {{ verta($fromDate)->format('Y/n/j') }} - تا - تاریخ - {{ verta($toDate)->format('Y/n/j') }} - From 79e6cc37aaf479c7d66d31bee26b43a92dcb0575 Mon Sep 17 00:00:00 2001 From: amirghasempoor Date: Sat, 19 Apr 2025 14:19:45 +0330 Subject: [PATCH 05/10] debug the blades --- app/Exports/V3/SafetyAndPrivacy/ProvinceActivityReport.php | 2 -- .../v3/Reports/SafetyAndPrivacy/CountryActivityReport.blade.php | 2 +- .../Reports/SafetyAndPrivacy/ProvinceActivityReport.blade.php | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/Exports/V3/SafetyAndPrivacy/ProvinceActivityReport.php b/app/Exports/V3/SafetyAndPrivacy/ProvinceActivityReport.php index 8e839d90..17b1e853 100644 --- a/app/Exports/V3/SafetyAndPrivacy/ProvinceActivityReport.php +++ b/app/Exports/V3/SafetyAndPrivacy/ProvinceActivityReport.php @@ -41,8 +41,6 @@ class ProvinceActivityReport implements FromView, WithEvents, ShouldAutoSize, Wi return view('v3.Reports.SafetyAndPrivacy.ProvinceActivityReport', [ 'data' => $data, - 'fromDate' => $data['fromDate'], - 'toDate' => $data['toDate'], ]); } diff --git a/resources/views/v3/Reports/SafetyAndPrivacy/CountryActivityReport.blade.php b/resources/views/v3/Reports/SafetyAndPrivacy/CountryActivityReport.blade.php index 72009c19..ee8c6c6a 100644 --- a/resources/views/v3/Reports/SafetyAndPrivacy/CountryActivityReport.blade.php +++ b/resources/views/v3/Reports/SafetyAndPrivacy/CountryActivityReport.blade.php @@ -28,7 +28,7 @@ - گزارش نگهداری حریم راه از تاریخ + گزارش نگهداری حریم راه diff --git a/resources/views/v3/Reports/SafetyAndPrivacy/ProvinceActivityReport.blade.php b/resources/views/v3/Reports/SafetyAndPrivacy/ProvinceActivityReport.blade.php index b5db906f..df2f7638 100644 --- a/resources/views/v3/Reports/SafetyAndPrivacy/ProvinceActivityReport.blade.php +++ b/resources/views/v3/Reports/SafetyAndPrivacy/ProvinceActivityReport.blade.php @@ -28,7 +28,7 @@ - گزارش نگهداری حریم راه از تاریخ + گزارش نگهداری حریم راه From 1cb4c4f15d63df0233fe2eac220562710ad66622 Mon Sep 17 00:00:00 2001 From: amirghasempoor Date: Sun, 20 Apr 2025 11:21:03 +0330 Subject: [PATCH 06/10] debug road observed --- .../Dashboard/RoadObservationController.php | 40 +++++------ .../Controllers/V3/NotificationController.php | 66 ++++++++----------- app/Models/RoadObserved.php | 10 ++- 3 files changed, 50 insertions(+), 66 deletions(-) diff --git a/app/Http/Controllers/V3/Dashboard/RoadObservationController.php b/app/Http/Controllers/V3/Dashboard/RoadObservationController.php index a3b97c4c..01291183 100644 --- a/app/Http/Controllers/V3/Dashboard/RoadObservationController.php +++ b/app/Http/Controllers/V3/Dashboard/RoadObservationController.php @@ -24,6 +24,7 @@ use Hekmatinasser\Verta\Verta; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use App\Services\Cartables\RoadObservationTableService; +use Illuminate\Support\Facades\DB; use Maatwebsite\Excel\Facades\Excel; use SoapFault; use Symfony\Component\HttpFoundation\BinaryFileResponse; @@ -117,8 +118,8 @@ class RoadObservationController extends Controller $roadObserved->files()->where('path', 'like', '%_image_before%')->delete(); $roadObserved->files()->where('path', 'like', '%_image_after%')->delete(); - $image_before = FileFacade::save($request->image_before, "road_observeds/{$roadObserved->id}/"); - $image_after = FileFacade::save($request->image_after, "road_observeds/{$roadObserved->id}/"); + $image_before = FileFacade::save($request->image_before, "road_observeds/{$roadObserved->id}"); + $image_after = FileFacade::save($request->image_after, "road_observeds/{$roadObserved->id}"); $files_path[0]['path'] = $image_before; $files_path[1]['path'] = $image_after; @@ -135,20 +136,15 @@ class RoadObservationController extends Controller $roadObservedHistoryData['new_files'] = $files; } - $roadObserved->problemHistories()->create($roadObservedHistoryData); - $roadObserved->update($roadObservedData); + DB::transaction(function () use ($roadObserved, $roadObservedHistoryData, $roadObservedData, $request, $nikarayanService) { + $roadObserved->problemHistories()->create($roadObservedHistoryData); + $roadObserved->update($roadObservedData); - auth()->user()->addActivityComplete(1142); + auth()->user()->addActivityComplete(1142); - try { $nikarayanService->updateRoadObservedInfoByNikarayan($request, $roadObserved, json_encode($roadObservedHistoryData['new_files'])); - } - catch (SoapFault $e) { - $msg = "error in send to nikarayan at" . date("Y-m-d H:i:s") . "\n"; - $msg .= $e->getMessage(); - Sms::sendSms(env('RMS_CTO_PHONE_NUMBER'), $msg); - } + }); return $this->successResponse(); } @@ -182,7 +178,7 @@ class RoadObservationController extends Controller if ($roadObserved->image_before) { FileFacade::delete($roadObserved->image_before, true); } - $image_before = FileFacade::save($request->image_before, "road_observeds/{$roadObserved->id}/"); + $image_before = FileFacade::save($request->image_before, "road_observeds/{$roadObserved->id}"); $roadObservedData['image_before'] = $image_before; $files_path[0]['path'] = $image_before; } @@ -191,7 +187,7 @@ class RoadObservationController extends Controller if ($roadObserved->image_after) { FileFacade::delete($roadObserved->image_after, true); } - $image_after = FileFacade::save($request->image_after, "road_observeds/{$roadObserved->id}/"); + $image_after = FileFacade::save($request->image_after, "road_observeds/{$roadObserved->id}"); $roadObservedData['image_after'] = $image_after; $files_path[1]['path'] = $image_after; } @@ -206,20 +202,14 @@ class RoadObservationController extends Controller $roadObservedHistoryData['new_files'] = $files; } - $roadObserved->problemHistories()->create($roadObservedHistoryData); - $roadObserved->update($roadObservedData); + DB::transaction(function () use ($roadObserved, $roadObservedHistoryData, $roadObservedData, $request, $nikarayanService) { + $roadObserved->problemHistories()->create($roadObservedHistoryData); + $roadObserved->update($roadObservedData); - auth()->user()->addActivityComplete(1142); + auth()->user()->addActivityComplete(1142); - try { $nikarayanService->updateRoadObservedInfoByNikarayan($request, $roadObserved, json_encode($roadObservedHistoryData['new_files'])); - } - catch (SoapFault $e) { - - $msg = "error in send to nikarayan at" . date("Y-m-d H:i:s") . "\n"; - $msg .= $e->getMessage(); - Sms::sendSms(env('RMS_CTO_PHONE_NUMBER'), $msg); - } + }); return $this->successResponse(); } diff --git a/app/Http/Controllers/V3/NotificationController.php b/app/Http/Controllers/V3/NotificationController.php index 01d4ae63..833ba72c 100644 --- a/app/Http/Controllers/V3/NotificationController.php +++ b/app/Http/Controllers/V3/NotificationController.php @@ -144,56 +144,44 @@ class NotificationController extends Controller 'supervise_cnt' => 0 ]; - $conditions = []; - $complaintConditions = [ - ['rms_status', '=', 0], - ['edarate_shahri_id', '!=', null] - ]; - if ($user->hasPermissionTo('show-fast-react')) { - $conditions[] = ['status', '=', 2]; + $road_observations['supervise_cnt'] = RoadObserved::query()->where([ + ['rms_status', '<>', 0], + ['status', '=', 0] + ])->count(); + + $road_observations['complaint_cnt'] = RoadObserved::query()->where('rms_status', '=', 0)->count(); } elseif ($user->hasPermissionTo('show-fast-react-province')) { throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!')); - $conditions = [ - ['status', '=', 2], - ['rms_province_id', '=', $user->province_id] - ]; - $complaintConditions[] = ['province_id', '=', $user->province_id]; + + $road_observations['supervise_cnt'] = RoadObserved::query()->where([ + ['rms_status', '<>', 0], + ['status', '=', 0], + ['province_id', '=', $user->province_id] + ])->count(); + + $road_observations['complaint_cnt'] = RoadObserved::query()->where([ + ['rms_status', '=', 0], + ['province_id', '=', $user->province_id] + ])->count(); } elseif ($user->hasPermissionTo('show-fast-react-edarate-shahri')) { throw_if(is_null($user->edarate_shahri_id), new ProhibitedAction('اداره ای برای شما در سامانه ثبت نشده است!')); - $conditions = [ + + $road_observations['operation_cnt'] = RoadObserved::query()->where([ + ['rms_status', '<>', 0], ['status', '=', 2], ['edarate_shahri_id', '=', $user->edarate_shahri_id] - ]; - $complaintConditions[] = ['edarate_shahri_id', '=', $user->edarate_shahri_id]; + ])->count(); + + $road_observations['complaint_cnt'] = RoadObserved::query()->where([ + ['rms_status', '=', 0], + ['edarate_shahri_id', '=', $user->edarate_shahri_id] + ])->count(); } - if (!empty($conditions)) { - $road_observations['operation_cnt'] = RoadObserved::query()->where($conditions)->count(); - $road_observations['complaint_cnt'] = RoadObserved::query()->where($complaintConditions)->count(); - $road_observations['total'] += $road_observations['operation_cnt'] + $road_observations['complaint_cnt']; - } - - $superviseConditions = [ - ['status', '=', 0] - ]; - - if ($user->hasPermissionTo('supervise-fast-react')) { - $road_observations['supervise_cnt'] = RoadObserved::query()->where($superviseConditions)->count(); - $road_observations['complaint_cnt'] = RoadObserved::query()->where($complaintConditions)->count(); - $road_observations['total'] += $road_observations['supervise_cnt'] + $road_observations['complaint_cnt']; - } - elseif ($user->hasPermissionTo('supervise-fast-react-province')) { - throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!')); - $superviseConditions[] = ['province_id', '=', $user->province_id]; - $complaintConditions[] = ['province_id', '=', $user->province_id]; - - $road_observations['supervise_cnt'] = RoadObserved::query()->where($superviseConditions)->count(); - $road_observations['complaint_cnt'] = RoadObserved::query()->where($complaintConditions)->count(); - $road_observations['total'] += $road_observations['supervise_cnt'] + $road_observations['complaint_cnt']; - } + $road_observations['total'] += $road_observations['operation_cnt'] + $road_observations['complaint_cnt'] + $road_observations['supervise_cnt']; return $road_observations; } diff --git a/app/Models/RoadObserved.php b/app/Models/RoadObserved.php index 18c4c9af..ce30a7a2 100644 --- a/app/Models/RoadObserved.php +++ b/app/Models/RoadObserved.php @@ -108,14 +108,20 @@ class RoadObserved extends Model protected function imageAfter(): Attribute { return Attribute::make( - get: fn($value) => $value == null ? null : Storage::disk('public')->url($value) + get: fn($value) => $value == null ? null : + (filter_var($value, FILTER_VALIDATE_URL) + ? $value + : Storage::disk('public')->url($value)) ); } protected function imageBefore(): Attribute { return Attribute::make( - get: fn($value) => $value == null ? null : Storage::disk('public')->url($value) + get: fn($value) => $value == null ? null : + (filter_var($value, FILTER_VALIDATE_URL) + ? $value + : Storage::disk('public')->url($value)) ); } } From 940c5d917af88ba31a51be9df418f09bab39e8b3 Mon Sep 17 00:00:00 2001 From: amirghasempoor Date: Sun, 20 Apr 2025 13:29:24 +0330 Subject: [PATCH 07/10] debug accident --- .../V3/Dashboard/AccidentReceiptController.php | 4 ++-- .../V3/Dashboard/RoadObservationController.php | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/V3/Dashboard/AccidentReceiptController.php b/app/Http/Controllers/V3/Dashboard/AccidentReceiptController.php index 5368e931..27620e3e 100644 --- a/app/Http/Controllers/V3/Dashboard/AccidentReceiptController.php +++ b/app/Http/Controllers/V3/Dashboard/AccidentReceiptController.php @@ -240,9 +240,9 @@ class AccidentReceiptController extends Controller DB::transaction(function () use ($request, $accident) { $accident->update([ - 'deposit_insurance_image' => $request->deposit_insurance_image != null ? FileFacade::save($request->deposit_insurance_image, "receipts_files/{$accident->id}/deposit_insurance/") : null, + 'deposit_insurance_image' => $request->has('deposit_insurance_image') ? FileFacade::save($request->deposit_insurance_image, "receipts_files/{$accident->id}/deposit_insurance") : null, 'deposit_insurance_amount' => $request->deposit_insurance_amount ?? 0, - 'deposit_daghi_image' => $request->deposit_insurance_image != null ? FileFacade::save($request->deposit_daghi_image, "receipts_files/{$accident->id}/deposit_daghi/") : null, + 'deposit_daghi_image' => $request->has('deposit_daghi_image') ? FileFacade::save($request->deposit_daghi_image, "receipts_files/{$accident->id}/deposit_daghi") : null, 'deposit_daghi_amount' => $request->deposit_daghi_amount ?? 0, 'status' => AccidentStates::SABT_FISH->value, 'status_fa' => AccidentStates::name(AccidentStates::SABT_FISH->value), diff --git a/app/Http/Controllers/V3/Dashboard/RoadObservationController.php b/app/Http/Controllers/V3/Dashboard/RoadObservationController.php index 01291183..8cdd32c7 100644 --- a/app/Http/Controllers/V3/Dashboard/RoadObservationController.php +++ b/app/Http/Controllers/V3/Dashboard/RoadObservationController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\V3\Dashboard; use App\Exports\V3\RoadObservation\ComplaintsReport; use App\Exports\V3\RoadObservation\OperatorCartableReport; use App\Exports\V3\RoadObservation\SupervisorCartableReport; +use App\Facades\DataTable\DataTableFacade; use App\Facades\File\FileFacade; use App\Facades\Sms\Sms; use App\Http\Controllers\Controller; @@ -295,4 +296,15 @@ class RoadObservationController extends Controller return $this->successResponse(); } + + public function map(Request $request): JsonResponse + { + return response()->json(DataTableFacade::run( + RoadObserved::query(), + $request, + allowedFilters: ['*'], + allowedSortings: ['*'], + allowedSelects: ['id', 'lat', 'lng', 'status'] + )); + } } From 88bcf8e49ec11f32a33218bfad29769223eac988 Mon Sep 17 00:00:00 2001 From: amirghasempoor Date: Sun, 20 Apr 2025 13:45:15 +0330 Subject: [PATCH 08/10] delete directory --- app/Facades/File/File.php | 5 +++++ .../Controllers/V3/Dashboard/AccidentReceiptController.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Facades/File/File.php b/app/Facades/File/File.php index 79155a8e..418f7664 100644 --- a/app/Facades/File/File.php +++ b/app/Facades/File/File.php @@ -104,4 +104,9 @@ class File fclose($file); return trim($output); } + + public function deleteDirectory(string $path, string $disk = 'public'): void + { + Storage::disk($disk)->deleteDirectory($path); + } } diff --git a/app/Http/Controllers/V3/Dashboard/AccidentReceiptController.php b/app/Http/Controllers/V3/Dashboard/AccidentReceiptController.php index 27620e3e..3b314a2d 100644 --- a/app/Http/Controllers/V3/Dashboard/AccidentReceiptController.php +++ b/app/Http/Controllers/V3/Dashboard/AccidentReceiptController.php @@ -202,7 +202,7 @@ class AccidentReceiptController extends Controller public function destroy(Accident $accident): JsonResponse { - FileFacade::delete('storage/receipts_files/'.$accident->id); + FileFacade::deleteDirectory('receipts_files/'.$accident->id); DB::transaction(function () use ($accident) { From b677624d5d6f6ab0ecadd90e20ca819164c137cc Mon Sep 17 00:00:00 2001 From: amirghasempoor Date: Sun, 20 Apr 2025 15:54:34 +0330 Subject: [PATCH 09/10] debug excel blades --- app/Services/Cartables/RoadItemTableService.php | 2 +- app/Services/DataTable/DataTableService.php | 3 +-- .../v3/Reports/RoadItems/OperatorCartableReport.blade.php | 3 +-- .../v3/Reports/RoadItems/SupervisorCartableReport.blade.php | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/Services/Cartables/RoadItemTableService.php b/app/Services/Cartables/RoadItemTableService.php index 0b64e741..2638e5c5 100644 --- a/app/Services/Cartables/RoadItemTableService.php +++ b/app/Services/Cartables/RoadItemTableService.php @@ -53,7 +53,7 @@ class RoadItemTableService $allowedSortings = ['*']; $query = RoadItemsProject::query() - ->select(['id', 'supervisor_description', 'item', 'item_fa', 'sub_item', 'sub_item_fa', 'sub_item_data', 'unit_fa', 'start_lat', 'start_lng', + ->select(['id', 'province_fa', 'edarat_name', 'supervisor_description', 'item', 'item_fa', 'sub_item', 'sub_item_fa', 'sub_item_data', 'unit_fa', 'start_lat', 'start_lng', 'end_lat', 'end_lng', 'activity_date_time', 'created_at', 'status_fa', 'status']) ->where('is_new', 1) ->where('user_id', auth()->user()->id) diff --git a/app/Services/DataTable/DataTableService.php b/app/Services/DataTable/DataTableService.php index 442f6e48..5755ad1d 100644 --- a/app/Services/DataTable/DataTableService.php +++ b/app/Services/DataTable/DataTableService.php @@ -80,6 +80,7 @@ class DataTableService $query = $this->applySelect($query, $this->allowedSelects); $query = $this->includeRelationsInQuery($query, $this->allowedRelations); + $query = $this->applyGroupBy($query, $this->allowedGroupBy); $this->totalRowCount = $query->count(); @@ -96,8 +97,6 @@ class DataTableService $query = (new ApplySort($query, $sort))->apply(); } - $query = $this->applyGroupBy($query, $this->allowedGroupBy); - return $query; } diff --git a/resources/views/v3/Reports/RoadItems/OperatorCartableReport.blade.php b/resources/views/v3/Reports/RoadItems/OperatorCartableReport.blade.php index 3894defd..76431163 100644 --- a/resources/views/v3/Reports/RoadItems/OperatorCartableReport.blade.php +++ b/resources/views/v3/Reports/RoadItems/OperatorCartableReport.blade.php @@ -97,7 +97,7 @@ {{ $item['sub_item_data'] ? ($item['unit_fa'] ? $item['sub_item_data'] . '(' . $item['unit_fa'] . ')' : $item['sub_item_data'] . '(-)') : '-' }} - {{ $item['cmms_machines'] != null ? $item['cmms_machines']->pluck('machine_code')->implode(', ') : '-' }} + {{ $item['cmmsMachines'] != null ? $item['cmmsMachines']->pluck('machine_code')->implode(', ') : '-' }} {{ $item['rahdaran'] != null ? $item['rahdaran']->pluck('code')->implode(', ') : '-' }} {{ isset($item['start_lat']) && isset($item['start_lng']) ? $item['start_lat'] . ' ' . $item['start_lng'] : '-' }} @@ -114,5 +114,4 @@ - diff --git a/resources/views/v3/Reports/RoadItems/SupervisorCartableReport.blade.php b/resources/views/v3/Reports/RoadItems/SupervisorCartableReport.blade.php index 6203dbbc..d7bb9a9f 100644 --- a/resources/views/v3/Reports/RoadItems/SupervisorCartableReport.blade.php +++ b/resources/views/v3/Reports/RoadItems/SupervisorCartableReport.blade.php @@ -97,7 +97,7 @@ {{ $item['sub_item_data'] ? ($item['unit_fa'] ? $item['sub_item_data'] . '(' . $item['unit_fa'] . ')' : $item['sub_item_data'] . '(-)') : '-' }} - {{ $item['cmms_machines'] != null ? $item['cmms_machines']->pluck('machine_code')->implode(', ') : '-' }} + {{ $item['cmmsMachines'] != null ? $item['cmmsMachines']->pluck('machine_code')->implode(', ') : '-' }} {{ $item['rahdaran'] != null ? $item['rahdaran']->pluck('code')->implode(', ') : '-' }} {{ isset($item['start_lat']) && isset($item['start_lng']) ? $item['start_lat'] . ' ' . $item['start_lng'] : '-' }} From bb4904a38f0b0f9c0d63dff3814f06b2ae73701b Mon Sep 17 00:00:00 2001 From: amirghasempoor Date: Sun, 20 Apr 2025 16:32:11 +0330 Subject: [PATCH 10/10] edit excels --- .../v3/Reports/RoadPatrols/OperatorCartableReport.blade.php | 2 +- .../v3/Reports/RoadPatrols/SupervisorCartableReport.blade.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/views/v3/Reports/RoadPatrols/OperatorCartableReport.blade.php b/resources/views/v3/Reports/RoadPatrols/OperatorCartableReport.blade.php index c90cb1da..92e1f1d6 100644 --- a/resources/views/v3/Reports/RoadPatrols/OperatorCartableReport.blade.php +++ b/resources/views/v3/Reports/RoadPatrols/OperatorCartableReport.blade.php @@ -74,7 +74,7 @@ {{ $item['id'] ?? '-' }} {{ $item['province_fa'] ?? '-' }} {{ $item['edare_name'] ?? '-' }} - {{ $item['cmms_machines'] != null ? $item['cmms_machines']->pluck('machine_code')->implode(', ') : '-' }} + {{ $item['cmmsMachines'] != null ? $item['cmmsMachines']->pluck('machine_code')->implode(', ') : '-' }} {{ $item['rahdaran'] != null ? $item['rahdaran']->pluck('code')->implode(', ') : '-' }} {{ $item['start_time'] ? verta($item['start_time'])->format('Y/n/j H:i:s') : '-' }} {{ $item['end_time'] ? verta($item['end_time'])->format('Y/n/j H:i:s') : '-' }} diff --git a/resources/views/v3/Reports/RoadPatrols/SupervisorCartableReport.blade.php b/resources/views/v3/Reports/RoadPatrols/SupervisorCartableReport.blade.php index 0fb2a3d1..af572a66 100644 --- a/resources/views/v3/Reports/RoadPatrols/SupervisorCartableReport.blade.php +++ b/resources/views/v3/Reports/RoadPatrols/SupervisorCartableReport.blade.php @@ -33,7 +33,7 @@ + style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;"> گزارش کارتابل ارزیابی گشت راهداری @@ -74,7 +74,7 @@ {{ $item['id'] ?? '-' }} {{ $item['province_fa'] ?? '-' }} {{ $item['edare_name'] ?? '-' }} - {{ $item['cmms_machines'] != null ? $item['cmms_machines']->pluck('machine_code')->implode(', ') : '-' }} + {{ $item['cmmsMachines'] != null ? $item['cmmsMachines']->pluck('machine_code')->implode(', ') : '-' }} {{ $item['rahdaran'] != null ? $item['rahdaran']->pluck('code')->implode(', ') : '-' }} {{ $item['start_time'] ? verta($item['start_time'])->format('Y/n/j H:i:s') : '-' }} {{ $item['end_time'] ? verta($item['end_time'])->format('Y/n/j H:i:s') : '-' }}