Merge branch 'develop' into 'main'
Develop See merge request witelgroup/rms_v2!109
This commit is contained in:
@@ -24,7 +24,7 @@ class RoadObservationProblems extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'webservice:roadobserved';
|
||||
protected $signature = 'webservice:roadobserved {--daily-mode}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -63,7 +63,9 @@ class RoadObservationProblems extends Command
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
$result = $nikarayanService->getRoadObservedProblemsByDate();
|
||||
$time = $this->option('daily-mode') ? verta()->subDay() : verta();
|
||||
|
||||
$result = $nikarayanService->getRoadObservedProblemsByDate($time);
|
||||
|
||||
$result = serialize($result);
|
||||
$x = strpos($result, '<Document');
|
||||
@@ -81,7 +83,7 @@ class RoadObservationProblems extends Command
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($value->fk_FeatureType >= 1 && $value->fk_FeatureType <= 18) {
|
||||
if ($value->fk_FeatureType >= 1 && $value->fk_FeatureType <= 24) {
|
||||
$mobile = null;
|
||||
|
||||
if ($value->MobileForSendEventSms && (strlen($value->MobileForSendEventSms) == 11)) {
|
||||
@@ -89,7 +91,7 @@ class RoadObservationProblems extends Command
|
||||
}
|
||||
|
||||
$city = findCityFromGeoJson($value->YGeo, $value->XGeo);
|
||||
$cityModel = $city ? City::find($city['city_id']) : null;
|
||||
$cityModel = $city ? City::query()->find($city['city_id']) : City::query()->find(NikarayanComplaints::mapCities((int) $value->fk_Town));
|
||||
$rop = RoadObserved::query()->updateOrCreate(
|
||||
['fk_RegisteredEventMessage' => $value->fk_RegisteredEventMessage],
|
||||
[
|
||||
@@ -99,7 +101,7 @@ class RoadObservationProblems extends Command
|
||||
'EndTime' => $value->EndTime ?? null,
|
||||
'StartDate' => $value->StartDate ?? null,
|
||||
'EndDate' => $value->EndDate ?? null,
|
||||
'StartTime_DateTime' => $value->StartTime_DateTime ?? null,
|
||||
'StartTime_DateTime' => $value->StartTime_DateTime ? Carbon::createFromFormat('m/d/Y h:i:s A', $value->StartTime_DateTime)->format('Y-m-d H:i:s') : null,
|
||||
'StartTime_DateTime_fa' => Verta::instance($value->StartTime_DateTime) ?? null,
|
||||
'EndTime_DateTime' => $value->EndTime_DateTime ?? null,
|
||||
'AutoID' => $value->AutoID ?? null,
|
||||
@@ -130,7 +132,7 @@ class RoadObservationProblems extends Command
|
||||
'province_id' => $city ? $city['province_id'] : null,
|
||||
'city_id' => $city ? $city['city_id'] : null,
|
||||
// 'handler_type' => EdarateShahri::class,
|
||||
'edarate_shahri_id' => $cityModel ? ($cityModel->edarateShahri()->where('is_primary', 1)->exists() ? $cityModel->edarateShahri()->where('is_primary', 1)->first()->id : null) : null,
|
||||
'edarate_shahri_id' => $cityModel->edarateShahri()->first()->id,
|
||||
'province_fa' => (isset($city['province_id']) ? Province::find($city['province_id'])->name_fa : null),
|
||||
'city_fa' => $cityModel ? $cityModel->name_fa : null,
|
||||
]
|
||||
|
||||
@@ -33,16 +33,14 @@ class SendRoadObservationToNikarayanCommand extends Command
|
||||
$this->info("Dispatching jobs with a delay between each...");
|
||||
|
||||
DB::transaction(function () use (&$count) {
|
||||
$delay = 0;
|
||||
RoadObserved::query()
|
||||
->whereBetween('StartTime_DateTime_fa', ['1403-01-01 00:00:00', '1403-07-13 23:59:59'])
|
||||
->chunkById(50, function ($roads) use (&$delay, &$count) {
|
||||
->chunkById(50, function ($roads) use (&$count) {
|
||||
foreach ($roads as $road) {
|
||||
$road->update(['status' => 1]);
|
||||
SendRoadObservationToNikarayan::dispatch($road)->delay(now()->addSeconds($delay));
|
||||
Log::channel('road_observation_problem')->info("Job for Road Observed ID {$road->id} scheduled with a {$delay} seconds delay.");
|
||||
$this->info("Scheduled job for Road ID: {$road->id} {$delay}s");
|
||||
$delay += 3;
|
||||
SendRoadObservationToNikarayan::dispatch($road);
|
||||
Log::channel('road_observation_problem')->info("Job for Road Observed ID {$road->id} scheduled.");
|
||||
$this->info("Scheduled job for Road ID: {$road->id}");
|
||||
$count +=1;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@ class Kernel extends ConsoleKernel
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$schedule->command('webservice:roadobserved')
|
||||
->everyFiveMinutes()->appendOutputTo(storage_path('logs/roadobser.log'));
|
||||
->everyFiveMinutes()->appendOutputTo(storage_path('logs/nikarayan.log'));
|
||||
|
||||
$schedule->command('command:sendcontractsmsnotification')
|
||||
// ->everyMinute()->appendOutputTo(storage_path('logs/contractSms.log'));
|
||||
@@ -35,7 +35,8 @@ class Kernel extends ConsoleKernel
|
||||
$schedule->command('reports:rms-summary')
|
||||
->dailyAt('00:00')->appendOutputTo(storage_path('logs/report_summary.log'));
|
||||
|
||||
|
||||
$schedule->command("webservice:roadobserved --daily-mode")
|
||||
->dailyAt('00:15')->appendOutputTo(storage_path('logs/nikarayan.log'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2636,7 +2636,37 @@ enum NikarayanComplaints: int
|
||||
"CityName" => "خرمدره",
|
||||
"ProvinceID" => "67",
|
||||
"InvarID" => 150
|
||||
]
|
||||
],
|
||||
432 => [
|
||||
"OnvarID" => 432,
|
||||
"CityName" => "جرقویه علیا",
|
||||
"ProvinceID" => "21",
|
||||
"InvarID" => 497
|
||||
],
|
||||
433 => [
|
||||
"OnvarID" => 433,
|
||||
"CityName" => "كوهپایه",
|
||||
"ProvinceID" => "21",
|
||||
"InvarID" => 793
|
||||
],
|
||||
434 => [
|
||||
"OnvarID" => 434,
|
||||
"CityName" => "ورزنه",
|
||||
"ProvinceID" => "21",
|
||||
"InvarID" => 805
|
||||
],
|
||||
435 => [
|
||||
"OnvarID" => 435,
|
||||
"CityName" => "هرند",
|
||||
"ProvinceID" => "21",
|
||||
"InvarID" => 794
|
||||
],
|
||||
436 => [
|
||||
"OnvarID" => 436,
|
||||
"CityName" => "جرقویه سفلی",
|
||||
"ProvinceID" => "21",
|
||||
"InvarID" => 497
|
||||
],
|
||||
];
|
||||
return $nikarayanToRmsCityId[$city_id]["InvarID"];
|
||||
}
|
||||
|
||||
21
app/Enums/RoadMaintenanceStationTypes.php
Normal file
21
app/Enums/RoadMaintenanceStationTypes.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum RoadMaintenanceStationTypes: int
|
||||
{
|
||||
case DAEMI= 1;
|
||||
case MOVAGHAT = 2;
|
||||
case FASLI = 3;
|
||||
|
||||
public static function name(int $state): string
|
||||
{
|
||||
$mapArray = [
|
||||
1 => "دائمی",
|
||||
2 => "موقت",
|
||||
3 => "فصلی",
|
||||
];
|
||||
|
||||
return $mapArray[$state];
|
||||
}
|
||||
}
|
||||
21
app/Enums/SafetyAndPrivacyStatus.php
Normal file
21
app/Enums/SafetyAndPrivacyStatus.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum SafetyAndPrivacyStatus: int
|
||||
{
|
||||
case PENDING = 0;
|
||||
case CONFIRM = 1;
|
||||
case REJECT = 2;
|
||||
|
||||
public static function name(int $state): string
|
||||
{
|
||||
$mapArray = [
|
||||
0 => 'در حال بررسی',
|
||||
1 => 'تایید',
|
||||
2 => 'عدم تایید',
|
||||
];
|
||||
|
||||
return $mapArray[$state];
|
||||
}
|
||||
}
|
||||
21
app/Enums/SafetyAndPrivacySteps.php
Normal file
21
app/Enums/SafetyAndPrivacySteps.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum SafetyAndPrivacySteps: int
|
||||
{
|
||||
case SHENASAEI= 1;
|
||||
case MOSTANADAT_GAZAEI = 2;
|
||||
case BARKHORD = 3;
|
||||
|
||||
public static function name(int $step): string
|
||||
{
|
||||
$mapArray = [
|
||||
1 => 'گام اول (شناسایی)',
|
||||
2 => 'گام دوم (مستندات قضایی)',
|
||||
3 => 'گام سوم (برخورد)',
|
||||
];
|
||||
|
||||
return $mapArray[$step];
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,13 +12,13 @@ use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class CartableReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
|
||||
class OperatorCartableReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
|
||||
{
|
||||
public function __construct(private ?Collection $data){}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
return view('v3.Reports.SafetyAndPrivacy.CartableReport', [
|
||||
return view('v3.Reports.SafetyAndPrivacy.OperatorCartableReport', [
|
||||
'data' => $this->data,
|
||||
]);
|
||||
}
|
||||
@@ -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,9 +40,7 @@ class ProvinceActivityReport implements FromView, WithEvents, ShouldAutoSize, Wi
|
||||
}
|
||||
|
||||
return view('v3.Reports.SafetyAndPrivacy.ProvinceActivityReport', [
|
||||
'data' => $data['activities'],
|
||||
'fromDate' => $data['fromDate'],
|
||||
'toDate' => $data['toDate'],
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
69
app/Exports/V3/SafetyAndPrivacy/SupervisorCartableReport.php
Normal file
69
app/Exports/V3/SafetyAndPrivacy/SupervisorCartableReport.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\V3\SafetyAndPrivacy;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class SupervisorCartableReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
|
||||
{
|
||||
public function __construct(private ?Collection $data){}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
return view('v3.Reports.SafetyAndPrivacy.SupervisorCartableReport', [
|
||||
'data' => $this->data,
|
||||
]);
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings(): array
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet): array
|
||||
{
|
||||
return [
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,8 @@ class DataTable
|
||||
array $allowedFilters = [],
|
||||
array $allowedRelations = [],
|
||||
array $allowedSortings = [],
|
||||
array $allowedSelects = []
|
||||
array $allowedSelects = [],
|
||||
array $allowedGroupBy = []
|
||||
): 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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,6 +150,7 @@ class BiController extends Controller
|
||||
|
||||
public function getDiagram(Request $request)
|
||||
{
|
||||
ini_set('memory_limit', '-1');
|
||||
$subjectID = $request->subject_id;
|
||||
$provinceID = $request->province_id;
|
||||
$dateFrom = $request->from_date;
|
||||
@@ -1021,6 +1022,7 @@ class BiController extends Controller
|
||||
|
||||
public function separationActivityTypeRahdariActivities(Request $request)
|
||||
{
|
||||
ini_set('memory_limit', '-1');
|
||||
$dateFrom = $request->from_date;
|
||||
$dateTo = $request->to_date;
|
||||
$provinceID = $request->province_id ?? null;
|
||||
@@ -1198,4 +1200,4 @@ class BiController extends Controller
|
||||
'data' => round($camps, 2)
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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']),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,260 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard;
|
||||
|
||||
use App\Enums\RoadMaintenanceStationTypes;
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Facades\File\FileFacade;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\RoadMaintenanceStation\StoreRequest;
|
||||
use App\Http\Requests\V3\RoadMaintenanceStation\UpdateRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\City;
|
||||
use App\Models\Province;
|
||||
use App\Models\RahdariPoint;
|
||||
use App\Models\RahdariPointHistory;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
|
||||
class RoadMaintenanceStationController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$user = auth()->user();
|
||||
auth()->user()->addActivityComplete(1019);
|
||||
|
||||
$allowedFilters = ['*'];
|
||||
$allowedSortings = ['*'];
|
||||
|
||||
$province = $request->province;
|
||||
$status = $request->status;
|
||||
$type = $request->type;
|
||||
|
||||
$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));
|
||||
|
||||
if ($user->hasPermissionTo('show-tollhouse-province')) {
|
||||
$query->where('province_id', $user->province_id);
|
||||
}
|
||||
|
||||
$data = DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: $allowedFilters,
|
||||
allowedSortings: $allowedSortings
|
||||
);
|
||||
|
||||
|
||||
foreach ($data['data'] as &$stations) {
|
||||
if ($user->hasPermissionTo('edit-tollhouse')) {
|
||||
$stations['canEdit'] = 1;
|
||||
}
|
||||
elseif ($user->hasPermissionTo('edit-tollhouse-province') && $stations->province_id == $user->province_id) {
|
||||
$stations['canEdit'] = 1;
|
||||
}
|
||||
else {
|
||||
$stations['canEdit'] = 0;
|
||||
}
|
||||
|
||||
if ($user->hasPermissionTo('delete-tollhouse')) {
|
||||
$stations['canDelete'] = 1;
|
||||
}
|
||||
elseif ($user->hasPermissionTo('delete-tollhouse-province') && $stations->province_id == $user->province_id) {
|
||||
$stations['canDelete'] = 1;
|
||||
}
|
||||
else {
|
||||
$stations['canDelete'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(StoreRequest $request): JsonResponse
|
||||
{
|
||||
$province = Province::query()->find($request->province_id);
|
||||
|
||||
$city = City::query()->find($request->city_id);
|
||||
|
||||
$station = RahdariPoint::query()->create([
|
||||
'province_id' => $province->id,
|
||||
'province_name' => $province->name_fa,
|
||||
'city_id' => $city->id,
|
||||
'city_name' => $city->name_fa,
|
||||
'name' => $request->name,
|
||||
'status' => $request->status,
|
||||
'type' => $request->type,
|
||||
'type_fa' =>RoadMaintenanceStationTypes::name($request->type),
|
||||
'team_num' => $request->team_num,
|
||||
'staff_num' => $request->staff_num,
|
||||
'phone' => $request->phone,
|
||||
'responsible_name' => $request->responsible_name,
|
||||
'responsible_mobile' => $request->responsible_mobile,
|
||||
'successor_name' => $request->successor_name,
|
||||
'successor_mobile' => $request->successor_mobile,
|
||||
'machines_light' => $request->machines_light,
|
||||
'machines_sheavy' => $request->machines_sheavy,
|
||||
'machines_heavy' => $request->machines_heavy,
|
||||
'code' => $request->code,
|
||||
'lat' => $request->lat,
|
||||
'lng' => $request->lng,
|
||||
'updated_at_fa' => verta()->now()->format('Y/m/d H:i:s'),
|
||||
]);
|
||||
|
||||
$uploadPaths = [
|
||||
'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) {
|
||||
if ($request->hasFile($field)) {
|
||||
$station->files()->create([
|
||||
'path' => FileFacade::save($request->$field, $path)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(RahdariPoint $rahdariPoint): JsonResponse
|
||||
{
|
||||
return $this->successResponse($rahdariPoint->load('files'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(UpdateRequest $request, RahdariPoint $rahdariPoint): JsonResponse
|
||||
{
|
||||
$province = Province::query()->find($request->province_id);
|
||||
|
||||
$city = City::query()->find($request->city_id);
|
||||
|
||||
RahdariPointHistory::query()->create([
|
||||
'user_id' => $request->user()->id,
|
||||
'point_id' => $rahdariPoint->id,
|
||||
'previous_province_id' => $province->id,
|
||||
'previous_province_name' => $province->name_fa,
|
||||
'previous_city_id' => $city->id,
|
||||
'previous_city_name' => $city->name_fa,
|
||||
'previous_name' => $rahdariPoint->name,
|
||||
'previous_status' => $rahdariPoint->status,
|
||||
'previous_type' => $rahdariPoint->type,
|
||||
'previous_team_num' => $rahdariPoint->team_num,
|
||||
'previous_staff_num' => $rahdariPoint->staff_num,
|
||||
'previous_phone' => $rahdariPoint->phone,
|
||||
'previous_responsible_name' => $rahdariPoint->responsible_name,
|
||||
'previous_responsible_mobile' => $rahdariPoint->responsible_mobile,
|
||||
'previous_successor_name' => $rahdariPoint->successor_name,
|
||||
'previous_successor_mobile' => $rahdariPoint->successor_mobile,
|
||||
'previous_machines_light' => $rahdariPoint->machines_light,
|
||||
'previous_machines_sheavy' => $rahdariPoint->machines_sheavy,
|
||||
'previous_machines_heavy' => $rahdariPoint->machines_heavy,
|
||||
'previous_lat' => $rahdariPoint->lat,
|
||||
'previous_lng' => $rahdariPoint->lng,
|
||||
'new_files' => json_encode($rahdariPoint->files),
|
||||
]);
|
||||
|
||||
$rahdariPoint->update([
|
||||
'province_id' => $province->id,
|
||||
'province_name' => $province->name_fa,
|
||||
'city_id' => $city->id,
|
||||
'city_name' => $city->name_fa,
|
||||
'name' => $request->input('name'),
|
||||
'status' => $request->input('status'),
|
||||
'type' => $request->input('type',),
|
||||
'type_fa' => RoadMaintenanceStationTypes::name($request->type) ?? $rahdariPoint->type_fa,
|
||||
'team_num' => $request->input('team_num'),
|
||||
'staff_num' => $request->input('staff_num'),
|
||||
'phone' => $request->input('phone'),
|
||||
'responsible_name' => $request->input('responsible_name'),
|
||||
'responsible_mobile' => $request->input('responsible_mobile'),
|
||||
'successor_name' => $request->input('successor_name'),
|
||||
'successor_mobile' => $request->input('successor_mobile'),
|
||||
'machines_light' => $request->input('machines_light'),
|
||||
'machines_sheavy' => $request->input('machines_sheavy'),
|
||||
'machines_heavy' => $request->input('machines_heavy'),
|
||||
'lat' => $request->input('lat'),
|
||||
'lng' => $request->input('lng'),
|
||||
'lat_from' => $request->lat_from,
|
||||
'lng_from' => $request->lng_from,
|
||||
'geometry' => $request->geometry,
|
||||
'lat_to' => $request->lat_to,
|
||||
'lng_to' => $request->lng_to,
|
||||
'color' => $request->color,
|
||||
'updated_at_fa' => verta()->now()->format('Y/m/d H:i:s'),
|
||||
]);
|
||||
|
||||
$uploadFields = [
|
||||
'overview_files_1',
|
||||
'overview_files_2',
|
||||
'overview_files_3',
|
||||
'overview_files_4',
|
||||
'overview_files_5',
|
||||
];
|
||||
|
||||
foreach ($uploadFields as $index => $field) {
|
||||
if ($request->hasFile($field)) {
|
||||
$existingFile = $rahdariPoint->files->get($index);
|
||||
$path = FileFacade::save($request->$field, "road_stations/{$rahdariPoint->id}");
|
||||
|
||||
if ($existingFile) {
|
||||
FileFacade::delete($existingFile->path);
|
||||
$existingFile->update(['path' => $path]);
|
||||
} else {
|
||||
$rahdariPoint->files()->create(['path' => $path]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(RahdariPoint $rahdariPoint): JsonResponse
|
||||
{
|
||||
foreach ($rahdariPoint->files as $file) {
|
||||
FileFacade::delete($file->path);
|
||||
}
|
||||
$rahdariPoint->rahdariPointHistories()->delete();
|
||||
$rahdariPoint->files()->delete();
|
||||
$rahdariPoint->delete();
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function images(RahdariPoint $rahdariPoint): JsonResponse
|
||||
{
|
||||
return $this->successResponse($rahdariPoint->files()->orderBy('id')->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'],
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -24,6 +25,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 +119,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 +137,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 +179,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 +188,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 +203,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();
|
||||
}
|
||||
@@ -305,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']
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\SafetyAndPrivacy;
|
||||
|
||||
use App\Enums\AxisTypes;
|
||||
use App\Enums\SafetyAndPrivacyStatus;
|
||||
use App\Enums\SafetyAndPrivacySteps;
|
||||
use App\Exports\V3\SafetyAndPrivacy\OperatorCartableReport;
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Facades\File\FileFacade;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\SafetyAndPrivacy\FinishRequest;
|
||||
use App\Http\Requests\V3\SafetyAndPrivacy\FirstStepStoreRequest;
|
||||
use App\Http\Requests\V3\SafetyAndPrivacy\SecondStepStoreRequest;
|
||||
use App\Http\Requests\V3\SafetyAndPrivacy\ThirdStepStoreRequest;
|
||||
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\NominatimService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Throwable;
|
||||
|
||||
class OperatorController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function index(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse
|
||||
{
|
||||
return response()->json($safetyAndPrivacyTableService->operatorDatatable($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function excelReport(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): BinaryFileResponse
|
||||
{
|
||||
$name = 'گزارش از نگهداری حریم راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||
$data = $safetyAndPrivacyTableService->operatorDatatable($request);
|
||||
return Excel::download(new OperatorCartableReport($data['data']), $name);
|
||||
}
|
||||
|
||||
public function firstStepStore(FirstStepStoreRequest $request, NominatimService $nominatimService): JsonResponse
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
$coordinates = explode(',', $request->point);
|
||||
$item = InfoItem::query()
|
||||
->where('id', $request->info_id)
|
||||
->where('item', 17)
|
||||
->firstOrFail();
|
||||
|
||||
DB::transaction(function () use ($request, $coordinates, $item, $nominatimService, $user)
|
||||
{
|
||||
$step = SafetyAndPrivacySteps::SHENASAEI->value;
|
||||
$safety_and_privacy = SafetyAndPrivacy::query()->create([
|
||||
'lat' => $coordinates[0],
|
||||
'lon' => $coordinates[1],
|
||||
'operator_id' => $user->id,
|
||||
'operator_name' => $user->name,
|
||||
'province_id' => $user->province_id,
|
||||
'province_fa' => $user->province_fa,
|
||||
'info_id' => $item->id,
|
||||
'info_fa' => $item->sub_item_str,
|
||||
'city_id' => $user->city_id,
|
||||
'city_fa' => $user->city_fa,
|
||||
'activity_date_time' => $request->activity_date." ".$request->activity_time,
|
||||
'edare_shahri_id' => $user->edarate_shahri_id,
|
||||
'edare_shahri_name' => $user->edarate_shahri_name,
|
||||
'way_id' => $nominatimService->get_way_id_from_nominatim($coordinates[0], $coordinates[1]),
|
||||
'axis_type_id' => $request->axis_type_id,
|
||||
'axis_type_name' => AxisTypes::name($request->axis_type_id),
|
||||
'step' => $step,
|
||||
'step_fa' => SafetyAndPrivacySteps::name($step),
|
||||
'is_finished' => false,
|
||||
]);
|
||||
|
||||
$safety_and_privacy->recognize_picture = $request->has('recognize_picture') ?
|
||||
FileFacade::save($request->recognize_picture, "safety_and_privacy/{$safety_and_privacy->id}") :
|
||||
null;
|
||||
$safety_and_privacy->save();
|
||||
|
||||
$user->addActivityComplete(1134);
|
||||
});
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function secondStepStore(SafetyAndPrivacy $safetyAndPrivacy, SecondStepStoreRequest $request): JsonResponse
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
DB::transaction(function () use ($request, $safetyAndPrivacy, $user) {
|
||||
|
||||
$need_judiciary = $request->need_judiciary;
|
||||
|
||||
$judiciary_document = [];
|
||||
if ($need_judiciary) {
|
||||
foreach ($request->judiciary_document as $index => $file) {
|
||||
$judiciary_document[] = FileFacade::save(
|
||||
$file,
|
||||
"safety_and_privacy/{$safetyAndPrivacy->id}/judiciary_document"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$step = SafetyAndPrivacySteps::MOSTANADAT_GAZAEI->value;
|
||||
$safetyAndPrivacy->update([
|
||||
'step' => $step,
|
||||
'step_fa' => SafetyAndPrivacySteps::name($step),
|
||||
'judiciary_document' => $need_judiciary ? serialize($judiciary_document) : null,
|
||||
'judiciary_document_upload_date' => $need_judiciary ? now() : null,
|
||||
'need_judiciary' => $need_judiciary,
|
||||
'operator_description' => $request->operator_description,
|
||||
]);
|
||||
|
||||
$user->addActivityComplete(1135);
|
||||
});
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function thirdStepStore(SafetyAndPrivacy $safetyAndPrivacy, ThirdStepStoreRequest $request): JsonResponse
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
DB::transaction(function () use ($request, $safetyAndPrivacy, $user) {
|
||||
$step = SafetyAndPrivacySteps::BARKHORD->value;
|
||||
$safetyAndPrivacy->update([
|
||||
'step' => $step,
|
||||
'step_fa' => SafetyAndPrivacySteps::name($step),
|
||||
'action_picture' => FileFacade::save($request->action_picture, "safety_and_privacy/{$safetyAndPrivacy->id}/action_picture"),
|
||||
'action_picture_document_upload_date' => now(),
|
||||
'action_date' => $request->action_date,
|
||||
'is_finished' => true,
|
||||
'final_description' => 'پیام سیستمی : این عملیات پس از طی تمامی گام ها خاتمه یافت'
|
||||
]);
|
||||
|
||||
$user->addActivityComplete(1136);
|
||||
});
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function update(SafetyAndPrivacy $safetyAndPrivacy, UpdateRequest $request): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request, $safetyAndPrivacy) {
|
||||
$safetyAndPrivacy->update([
|
||||
'axis_type_id' => $request->axis_type_id,
|
||||
'axis_type_name' => AxisTypes::name($request->axis_type_id),
|
||||
]);
|
||||
|
||||
auth()->user()->addActivityComplete(1168);
|
||||
});
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function show(SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
|
||||
{
|
||||
return $this->successResponse($safetyAndPrivacy);
|
||||
}
|
||||
|
||||
public function destroy(SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
|
||||
{
|
||||
FileFacade::deleteDirectory("safety_and_privacy/{$safetyAndPrivacy->id}");
|
||||
|
||||
DB::transaction(function () use ($safetyAndPrivacy)
|
||||
{
|
||||
auth()->user()->addActivityComplete(1155);
|
||||
$safetyAndPrivacy->delete();
|
||||
});
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function deserialize(SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
|
||||
{
|
||||
$judiciaries = $safetyAndPrivacy->judiciary_document ? unserialize($safetyAndPrivacy->judiciary_document) : [];
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($judiciaries as $judiciary) {
|
||||
$result[] = Storage::disk('public')->url($judiciary);
|
||||
}
|
||||
|
||||
return $this->successResponse($result);
|
||||
}
|
||||
|
||||
public function subItems(): JsonResponse
|
||||
{
|
||||
return $this->successResponse(InfoItem::query()
|
||||
->where('item', '=', 17)
|
||||
->select('id', 'item', 'item_str', 'sub_item_str as name', 'sub_item_unit as unit', 'needs_image', 'needs_end_point', 'sub_item')
|
||||
->get());
|
||||
}
|
||||
|
||||
public function finish(FinishRequest $request, SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
|
||||
{
|
||||
$status_id = SafetyAndPrivacyStatus::PENDING->value;
|
||||
|
||||
$safetyAndPrivacy->update([
|
||||
'is_finished' => 1,
|
||||
'final_description' => $request->final_description,
|
||||
'status' => $status_id,
|
||||
'status_fa' => SafetyAndPrivacyStatus::name($status_id),
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function map(Request $request): JsonResponse
|
||||
{
|
||||
return response()->json(DataTableFacade::run(
|
||||
SafetyAndPrivacy::query(),
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
allowedSelects: ['id', 'lat', 'lon', 'step']
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\SafetyAndPrivacy;
|
||||
|
||||
use App\Exports\V3\SafetyAndPrivacy\CountryActivityReport;
|
||||
use App\Exports\V3\SafetyAndPrivacy\ProvinceActivityReport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\EdarateShahri;
|
||||
use App\Models\Province;
|
||||
use App\Services\Cartables\SafetyAndPrivacyTableService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
class OperatorReportController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function countryActivity(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse
|
||||
{
|
||||
$data = $safetyAndPrivacyTableService->countryActivity($request);
|
||||
return $this->successResponse([
|
||||
'activities' => $data,
|
||||
'provinces' => Province::all(['id', 'name_fa'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function provinceActivity(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse
|
||||
{
|
||||
$data = $safetyAndPrivacyTableService->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
|
||||
{
|
||||
$data = $safetyAndPrivacyTableService->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
|
||||
{
|
||||
$data = $safetyAndPrivacyTableService->provinceActivity($request);
|
||||
$name = 'گزارش از نگهداری حریم راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||
return Excel::download(new ProvinceActivityReport($data, $request), $name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\SafetyAndPrivacy;
|
||||
|
||||
use App\Enums\SafetyAndPrivacyStatus;
|
||||
use App\Exports\V3\SafetyAndPrivacy\SupervisorCartableReport;
|
||||
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\SafetyAndPrivacyTableService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Throwable;
|
||||
|
||||
class SupervisorController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function index(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse
|
||||
{
|
||||
return response()->json($safetyAndPrivacyTableService->supervisorDataTable($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function excelReport(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): BinaryFileResponse
|
||||
{
|
||||
$name = 'گزارش از نگهداری حریم راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||
$data = $safetyAndPrivacyTableService->supervisorDataTable($request);
|
||||
return Excel::download(new SupervisorCartableReport($data['data']), $name);
|
||||
}
|
||||
|
||||
public function confirm(SafetyAndPrivacy $safetyAndPrivacy, Request $request): JsonResponse
|
||||
{
|
||||
$status_id = SafetyAndPrivacyStatus::CONFIRM->value;
|
||||
|
||||
$safetyAndPrivacy->update([
|
||||
'status' => $status_id,
|
||||
'status_fa' => SafetyAndPrivacyStatus::name($status_id),
|
||||
'supervisor_description' => $request->supervisor_description,
|
||||
'supervisor_id' => auth()->user()->id,
|
||||
'supervisor_name' => auth()->user()->name,
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function reject(RejectRequest $request, SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
|
||||
{
|
||||
$status_id = SafetyAndPrivacyStatus::REJECT->value;
|
||||
|
||||
$safetyAndPrivacy->update([
|
||||
'status' => $status_id,
|
||||
'status_fa' => SafetyAndPrivacyStatus::name($status_id),
|
||||
'supervisor_description' => $request->supervisor_description,
|
||||
'supervisor_id' => auth()->user()->id,
|
||||
'supervisor_name' => auth()->user()->name,
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\SafetyAndPrivacy;
|
||||
|
||||
use App\Enums\SafetyAndPrivacyStatus;
|
||||
use App\Exports\V3\SafetyAndPrivacy\CountryActivityReport;
|
||||
use App\Exports\V3\SafetyAndPrivacy\ProvinceActivityReport;
|
||||
use App\Exports\V3\SafetyAndPrivacy\SupervisorCartableReport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\SafetyAndPrivacy\RejectRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\EdarateShahri;
|
||||
use App\Models\Province;
|
||||
use App\Models\SafetyAndPrivacy;
|
||||
use App\Services\Cartables\SafetyAndPrivacyTableService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
class SupervisorReportController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function countryActivity(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse
|
||||
{
|
||||
$data = $safetyAndPrivacyTableService->countryActivity($request);
|
||||
return $this->successResponse([
|
||||
'activities' => $data,
|
||||
'provinces' => Province::all(['id', 'name_fa'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function provinceActivity(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse
|
||||
{
|
||||
$data = $safetyAndPrivacyTableService->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
|
||||
{
|
||||
$data = $safetyAndPrivacyTableService->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
|
||||
{
|
||||
$data = $safetyAndPrivacyTableService->provinceActivity($request);
|
||||
$name = 'گزارش از نگهداری حریم راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||
return Excel::download(new ProvinceActivityReport($data, $request), $name);
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,19 @@
|
||||
namespace App\Http\Controllers\V3\Dashboard;
|
||||
|
||||
use App\Enums\AxisTypes;
|
||||
use App\Exports\V3\SafetyAndPrivacy\CartableReport;
|
||||
use App\Enums\SafetyAndPrivacyStatus;
|
||||
use App\Enums\SafetyAndPrivacySteps;
|
||||
use App\Exports\V3\SafetyAndPrivacy\OperatorCartableReport;
|
||||
use App\Exports\V3\SafetyAndPrivacy\SupervisorCartableReport;
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Facades\File\FileFacade;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\SafetyAndPrivacy\FinishRequest;
|
||||
use App\Http\Requests\V3\SafetyAndPrivacy\RejectRequest;
|
||||
use App\Http\Requests\V3\SafetyAndPrivacy\FirstStepStoreRequest;
|
||||
use App\Http\Requests\V3\SafetyAndPrivacy\SecondStepStoreRequest;
|
||||
use App\Http\Requests\V3\SafetyAndPrivacy\ThirdStepStoreRequest;
|
||||
use App\Http\Requests\V3\SafetyAndPrivacy\UpdateRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\InfoItem;
|
||||
use App\Models\SafetyAndPrivacy;
|
||||
@@ -16,41 +23,38 @@ 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;
|
||||
|
||||
class SafetyAndPrivacyController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function index(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function operatorIndex(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse
|
||||
{
|
||||
return response()->json($safetyAndPrivacyTableService->datatable($request));
|
||||
return response()->json($safetyAndPrivacyTableService->operatorDatatable($request));
|
||||
}
|
||||
|
||||
public function excelReport(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): BinaryFileResponse
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function operatorExcelReport(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): BinaryFileResponse
|
||||
{
|
||||
$name = 'گزارش از نگهداری حریم راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||
$data = $safetyAndPrivacyTableService->datatable($request);
|
||||
return Excel::download(new CartableReport($data['data']), $name);
|
||||
$data = $safetyAndPrivacyTableService->operatorDatatable($request);
|
||||
return Excel::download(new OperatorCartableReport($data['data']), $name);
|
||||
}
|
||||
|
||||
public function firstStepStore(FirstStepStoreRequest $request, NominatimService $nominatimService): JsonResponse
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->edarate_ostani_id || is_null($user->city_id)) {
|
||||
return $this->errorResponse('امکان ثبت این مورد برای ادارات استانی و ستادی وجود ندارد!');
|
||||
}
|
||||
|
||||
if (is_null($user->edarate_shahri_id)) {
|
||||
return $this->errorResponse('اداره شهری برای شما در سامانه ثبت نشده است!');
|
||||
}
|
||||
|
||||
$coordinates = explode(',', $request->point);
|
||||
$item = InfoItem::query()
|
||||
->where('id', $request->info_id)
|
||||
@@ -59,6 +63,7 @@ class SafetyAndPrivacyController extends Controller
|
||||
|
||||
DB::transaction(function () use ($request, $coordinates, $item, $nominatimService, $user)
|
||||
{
|
||||
$step = SafetyAndPrivacySteps::SHENASAEI->value;
|
||||
$safety_and_privacy = SafetyAndPrivacy::query()->create([
|
||||
'lat' => $coordinates[0],
|
||||
'lon' => $coordinates[1],
|
||||
@@ -76,8 +81,9 @@ class SafetyAndPrivacyController extends Controller
|
||||
'way_id' => $nominatimService->get_way_id_from_nominatim($coordinates[0], $coordinates[1]),
|
||||
'axis_type_id' => $request->axis_type_id,
|
||||
'axis_type_name' => AxisTypes::name($request->axis_type_id),
|
||||
'step' => 1,
|
||||
'step_fa' => 'گام اول (شناسایی)'
|
||||
'step' => $step,
|
||||
'step_fa' => SafetyAndPrivacySteps::name($step),
|
||||
'is_finished' => false,
|
||||
]);
|
||||
|
||||
$safety_and_privacy->recognize_picture = $request->has('recognize_picture') ?
|
||||
@@ -95,25 +101,27 @@ class SafetyAndPrivacyController extends Controller
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->edarate_ostani_id || is_null($user->city_id)) {
|
||||
return $this->errorResponse('امکان ثبت این مورد برای ادارات استانی و ستادی وجود ندارد!');
|
||||
}
|
||||
DB::transaction(function () use ($request, $safetyAndPrivacy, $user) {
|
||||
|
||||
if (is_null($user->edarate_shahri_id)) {
|
||||
return $this->errorResponse('اداره شهری برای شما در سامانه ثبت نشده است!');
|
||||
}
|
||||
$need_judiciary = $request->need_judiciary;
|
||||
|
||||
DB::transaction(function () use ($request, $safetyAndPrivacy, $user)
|
||||
{
|
||||
$judiciary_document = [];
|
||||
foreach ($request->judiciary_document as $index => $file) {
|
||||
$judiciary_document[] = FileFacade::save($file, "safety_and_privacy/{$safetyAndPrivacy->id}/judiciary_document");
|
||||
if ($need_judiciary) {
|
||||
foreach ($request->judiciary_document as $index => $file) {
|
||||
$judiciary_document[] = FileFacade::save(
|
||||
$file,
|
||||
"safety_and_privacy/{$safetyAndPrivacy->id}/judiciary_document"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$step = SafetyAndPrivacySteps::MOSTANADAT_GAZAEI->value;
|
||||
$safetyAndPrivacy->update([
|
||||
'judiciary_document' => serialize($judiciary_document),
|
||||
'judiciary_document_upload_date' => now(),
|
||||
'step' => 2,
|
||||
'step_fa' => 'گام دوم (مستندات قضایی)'
|
||||
'step' => $step,
|
||||
'step_fa' => SafetyAndPrivacySteps::name($step),
|
||||
'judiciary_document' => $need_judiciary ? serialize($judiciary_document) : null,
|
||||
'judiciary_document_upload_date' => $need_judiciary ? now() : null,
|
||||
'need_judiciary' => $need_judiciary,
|
||||
]);
|
||||
|
||||
$user->addActivityComplete(1135);
|
||||
@@ -126,20 +134,16 @@ class SafetyAndPrivacyController extends Controller
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->edarate_ostani_id || is_null($user->city_id)) {
|
||||
return $this->errorResponse('امکان ثبت این مورد برای ادارات استانی و ستادی وجود ندارد!');
|
||||
}
|
||||
|
||||
if (is_null($user->edarate_shahri_id)) {
|
||||
return $this->errorResponse('اداره شهری برای شما در سامانه ثبت نشده است!');
|
||||
}
|
||||
|
||||
DB::transaction(function () use ($request, $safetyAndPrivacy, $user) {
|
||||
$step = SafetyAndPrivacySteps::BARKHORD->value;
|
||||
$safetyAndPrivacy->update([
|
||||
'step' => 3,
|
||||
'step_fa' => 'گام سوم (برخورد)',
|
||||
'step' => $step,
|
||||
'step_fa' => SafetyAndPrivacySteps::name($step),
|
||||
'action_picture' => FileFacade::save($request->action_picture, "safety_and_privacy/{$safetyAndPrivacy->id}/action_picture"),
|
||||
'action_picture_document_upload_date' => now(),
|
||||
'action_date' => $request->action_date,
|
||||
'is_finished' => true,
|
||||
'final_description' => 'پیام سیستمی : این عملیات پس از طی تمامی گام ها خاتمه یافت'
|
||||
]);
|
||||
|
||||
$user->addActivityComplete(1136);
|
||||
@@ -148,6 +152,20 @@ class SafetyAndPrivacyController extends Controller
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function update(SafetyAndPrivacy $safetyAndPrivacy, UpdateRequest $request): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request, $safetyAndPrivacy) {
|
||||
$safetyAndPrivacy->update([
|
||||
'axis_type_id' => $request->axis_type_id,
|
||||
'axis_type_name' => AxisTypes::name($request->axis_type_id),
|
||||
]);
|
||||
|
||||
auth()->user()->addActivityComplete(1168);
|
||||
});
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function show(SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
|
||||
{
|
||||
return $this->successResponse($safetyAndPrivacy);
|
||||
@@ -155,7 +173,7 @@ class SafetyAndPrivacyController extends Controller
|
||||
|
||||
public function destroy(SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
|
||||
{
|
||||
Storage::deleteDirectory("public/safety_and_privacy/{$safetyAndPrivacy->id}");
|
||||
FileFacade::deleteDirectory("safety_and_privacy/{$safetyAndPrivacy->id}");
|
||||
|
||||
DB::transaction(function () use ($safetyAndPrivacy)
|
||||
{
|
||||
@@ -186,4 +204,66 @@ class SafetyAndPrivacyController extends Controller
|
||||
->select('id', 'item', 'item_str', 'sub_item_str as name', 'sub_item_unit as unit', 'needs_image', 'needs_end_point', 'sub_item')
|
||||
->get());
|
||||
}
|
||||
|
||||
public function map(Request $request): JsonResponse
|
||||
{
|
||||
return response()->json(DataTableFacade::run(
|
||||
SafetyAndPrivacy::query(),
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
allowedSelects: ['id', 'lat', 'lon', 'step']
|
||||
));
|
||||
}
|
||||
|
||||
public function confirm(SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
|
||||
{
|
||||
$status_id = SafetyAndPrivacyStatus::CONFIRM->value;
|
||||
|
||||
$safetyAndPrivacy->update([
|
||||
'status' => $status_id,
|
||||
'status_fa' => SafetyAndPrivacyStatus::name($status_id),
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function reject(RejectRequest $request, SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
|
||||
{
|
||||
$status_id = SafetyAndPrivacyStatus::REJECT->value;
|
||||
|
||||
$safetyAndPrivacy->update([
|
||||
'status' => $status_id,
|
||||
'status_fa' => SafetyAndPrivacyStatus::name($status_id),
|
||||
'supervisor_description' => $request->supervisor_description
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function finish(FinishRequest $request, SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
|
||||
{
|
||||
$status_id = SafetyAndPrivacyStatus::PENDING->value;
|
||||
|
||||
$safetyAndPrivacy->update([
|
||||
'is_finished' => 1,
|
||||
'final_description' => $request->final_description,
|
||||
'status' => $status_id,
|
||||
'status_fa' => SafetyAndPrivacyStatus::name($status_id),
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function supervisorIndex(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse
|
||||
{
|
||||
return response()->json($safetyAndPrivacyTableService->supervisorDataTable($request));
|
||||
}
|
||||
|
||||
public function supervisorExcelReport(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): BinaryFileResponse
|
||||
{
|
||||
$name = 'گزارش از نگهداری حریم راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
|
||||
$data = $safetyAndPrivacyTableService->supervisorDataTable($request);
|
||||
return Excel::download(new SupervisorCartableReport($data['data']), $name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,24 +92,21 @@ class NotificationController extends Controller
|
||||
{
|
||||
$user = auth()->user();
|
||||
$safety_and_privacy = array();
|
||||
if ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable')) {
|
||||
$activity = SafetyAndPrivacy::query()
|
||||
->selectRaw('count(*) as cnt, step')
|
||||
->groupby('step')
|
||||
->orderBy('step')
|
||||
->get();
|
||||
|
||||
if ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable')) {
|
||||
$safety_and_privacy['supervise_cnt'] = SafetyAndPrivacy::query()
|
||||
->where('is_finished', '=', 1)
|
||||
->where('status', '=', 0)
|
||||
->count();
|
||||
}
|
||||
elseif ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-province')) {
|
||||
throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!'));
|
||||
|
||||
$activity = SafetyAndPrivacy::query()
|
||||
$safety_and_privacy['supervise_cnt'] = SafetyAndPrivacy::query()
|
||||
->where('province_id', '=', $user->province_id)
|
||||
->selectRaw('count(*) as cnt, step')
|
||||
->groupby('step')
|
||||
->orderBy('step')
|
||||
->get();
|
||||
|
||||
->where('is_finished', '=', 1)
|
||||
->where('status', '=', 0)
|
||||
->count();
|
||||
}
|
||||
elseif ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-edarate-shahri')) {
|
||||
throw_if(is_null($user->edarate_shahri_id), new ProhibitedAction('اداره ای برای شما در سامانه ثبت نشده است!'));
|
||||
@@ -117,13 +114,17 @@ class NotificationController extends Controller
|
||||
$activity = SafetyAndPrivacy::query()
|
||||
->where('edare_shahri_id', '=', $user->edarate_shahri_id)
|
||||
->selectRaw('count(*) as cnt, step')
|
||||
->where('is_finished', '=', 0)
|
||||
->groupby('step')
|
||||
->orderBy('step')
|
||||
->get();
|
||||
}
|
||||
|
||||
$safety_and_privacy['step_one'] = isset($activity[0]) ? $activity[0]->cnt : 0;
|
||||
$safety_and_privacy['step_two'] = isset($activity[1]) ? $activity[1]->cnt : 0;
|
||||
$step_one = $activity->where('step', '=', 1)->first();
|
||||
$step_two = $activity->where('step', '=', 2)->first();
|
||||
|
||||
$safety_and_privacy['step_one'] = $step_one->cnt ?? 0;
|
||||
$safety_and_privacy['step_two'] = $step_two->cnt ?? 0;
|
||||
}
|
||||
|
||||
return $safety_and_privacy;
|
||||
}
|
||||
@@ -141,56 +142,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;
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ class Kernel extends HttpKernel
|
||||
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
|
||||
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
|
||||
'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class,
|
||||
'validate-store-access' => \App\Http\Middleware\ValidateStoreAccess::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
32
app/Http/Middleware/ValidateStoreAccess.php
Normal file
32
app/Http/Middleware/ValidateStoreAccess.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Exceptions\ProhibitedAction;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Throwable;
|
||||
|
||||
class ValidateStoreAccess
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Closure(Request): (Response) $next
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
throw_if ($user->edarate_ostani_id || is_null($user->city_id),
|
||||
new ProhibitedAction('امکان ثبت این مورد برای ادارات استانی و ستادی وجود ندارد!'));
|
||||
|
||||
throw_if(is_null($user->edarate_shahri_id),
|
||||
new ProhibitedAction('اداره شهری برای شما در سامانه ثبت نشده است!'));
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
57
app/Http/Requests/V3/RoadMaintenanceStation/StoreRequest.php
Normal file
57
app/Http/Requests/V3/RoadMaintenanceStation/StoreRequest.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\RoadMaintenanceStation;
|
||||
|
||||
use App\Models\RahdariPoint;
|
||||
use Hekmatinasser\Verta\Facades\Verta;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class StoreRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
return $user->hasPermissionTo('add-tollhouse') ||
|
||||
($user->hasPermissionTo('add-tollhouse-province') && $this->province_id == $user->province_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 [
|
||||
'province_id' => 'required|exists:provinces,id',
|
||||
'city_id' => 'required|exists:cities,id',
|
||||
'name' => 'required|string|max:255',
|
||||
'status' => 'required|in:0,1',
|
||||
'type' =>'required|in:1,2,3',
|
||||
'team_num' => 'numeric',
|
||||
'staff_num' => 'numeric',
|
||||
'phone' => 'string|max:50',
|
||||
'responsible_name' => 'string|max:255',
|
||||
'responsible_mobile' => 'string|max:50',
|
||||
'successor_name' => 'string|max:255',
|
||||
'successor_mobile' => 'string|max:50',
|
||||
'machines_light' => 'numeric',
|
||||
'machines_sheavy' => 'numeric',
|
||||
'machines_heavy' => 'numeric',
|
||||
'code' => 'string|max:50',
|
||||
'lat' => 'numeric',
|
||||
'lng' => 'numeric',
|
||||
'overview_files_1' => 'file|mimes:jpg,jpeg,png,pdf|max:51200',
|
||||
'overview_files_2' => 'file|mimes:jpg,jpeg,png,pdf|max:51200',
|
||||
'overview_files_3' => 'file|mimes:jpg,jpeg,png,pdf|max:51200',
|
||||
'overview_files_4' => 'file|mimes:jpg,jpeg,png,pdf|max:51200',
|
||||
'overview_files_5' => 'file|mimes:jpg,jpeg,png,pdf|max:51200',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\RoadMaintenanceStation;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateRequest 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 [
|
||||
'province_id' => 'required|exists:provinces,id',
|
||||
'city_id' => 'required|exists:cities,id',
|
||||
'name' => 'required|string|max:255',
|
||||
'status' => 'integer|in:0,1',
|
||||
'type' => 'integer|in:1,2,3',
|
||||
'team_num' => 'numeric',
|
||||
'staff_num' => 'numeric',
|
||||
'phone' => 'string|max:50',
|
||||
'responsible_name' => 'string|max:255',
|
||||
'responsible_mobile' => 'string|max:50',
|
||||
'successor_name' => 'string|max:255',
|
||||
'successor_mobile' => 'string|max:50',
|
||||
'machines_light' => 'numeric',
|
||||
'machines_sheavy' => 'numeric',
|
||||
'machines_heavy' => 'numeric',
|
||||
'lat' => 'numeric',
|
||||
'lng' => 'numeric',
|
||||
'lat_from' => 'numeric',
|
||||
'lng_from' => 'numeric',
|
||||
'lat_to' => 'numeric',
|
||||
'lng_to' => 'numeric',
|
||||
'color' => 'numeric',
|
||||
'geometry' => 'numeric',
|
||||
'overview_files_1' => 'file|mimes:jpg,jpeg,png,pdf|max:5120',
|
||||
'overview_files_2' => 'file|mimes:jpg,jpeg,png,pdf|max:5120',
|
||||
'overview_files_3' => 'file|mimes:jpg,jpeg,png,pdf|max:5120',
|
||||
'overview_files_4' => 'file|mimes:jpg,jpeg,png,pdf|max:5120',
|
||||
'overview_files_5' => 'file|mimes:jpg,jpeg,png,pdf|max:5120',
|
||||
];
|
||||
}
|
||||
}
|
||||
28
app/Http/Requests/V3/SafetyAndPrivacy/FinishRequest.php
Normal file
28
app/Http/Requests/V3/SafetyAndPrivacy/FinishRequest.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\SafetyAndPrivacy;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class FinishRequest 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 [
|
||||
'final_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
28
app/Http/Requests/V3/SafetyAndPrivacy/RejectRequest.php
Normal file
28
app/Http/Requests/V3/SafetyAndPrivacy/RejectRequest.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\SafetyAndPrivacy;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class RejectRequest 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 [
|
||||
'supervisor_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,9 @@ class SecondStepStoreRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'judiciary_document' => 'required|array',
|
||||
'need_judiciary' => 'required|boolean',
|
||||
'operator_description' => 'required_if:need_judiciary,0|string',
|
||||
'judiciary_document' => 'required_if:need_judiciary,1|array',
|
||||
'judiciary_document.*' => 'file',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ class ThirdStepStoreRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
'action_picture' => 'required|image',
|
||||
'action_date' => 'required|date',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
28
app/Http/Requests/V3/SafetyAndPrivacy/UpdateRequest.php
Normal file
28
app/Http/Requests/V3/SafetyAndPrivacy/UpdateRequest.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\SafetyAndPrivacy;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateRequest 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 [
|
||||
'axis_type_id' => 'required|integer|exists:axis_types,id',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -45,12 +45,14 @@ class SendRoadObservationToNikarayan implements ShouldQueue
|
||||
);
|
||||
|
||||
$soapClient = new SoapClient($url);
|
||||
|
||||
$soapClient->UpdateInfo_RoadObservedProblems($array);
|
||||
$result = $soapClient->UpdateInfo_RoadObservedProblems($array);
|
||||
Log::channel('road_observation_problem')->info(json_encode($result), [$this->roadObserved->id]);
|
||||
}
|
||||
catch (\Exception $exception){
|
||||
Log::channel('road_observation_problem')->error($exception->getMessage(), [
|
||||
'roadObserved' => $this->roadObserved,
|
||||
'roadObserved' => $this->roadObserved->id,
|
||||
'line' => $exception->getLine(),
|
||||
'file' => $exception->getFile(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class PointFile extends Model
|
||||
{
|
||||
@@ -25,14 +28,23 @@ 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();
|
||||
}
|
||||
|
||||
protected function path(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn($value) => $value == null ? null : Storage::disk('public')->url($value)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
class RahdariPoint extends Model
|
||||
{
|
||||
@@ -69,15 +71,12 @@ class RahdariPoint extends Model
|
||||
'updated_at_fa',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get all of the point's files.
|
||||
*/
|
||||
public function files()
|
||||
public function files(): MorphMany
|
||||
{
|
||||
return $this->morphMany('App\Models\PointFile', 'point_fileable');
|
||||
}
|
||||
|
||||
public function rahdariPointHistories()
|
||||
public function rahdariPointHistories(): HasMany
|
||||
{
|
||||
return $this->hasMany('App\Models\RahdariPointHistory', 'point_id');
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,16 @@ class SafetyAndPrivacy extends Model
|
||||
'action_picture_document_upload_date',
|
||||
'axis_type_id',
|
||||
'axis_type_name',
|
||||
'action_date',
|
||||
'status',
|
||||
'final_description',
|
||||
'is_finished',
|
||||
'supervisor_description',
|
||||
'status_fa',
|
||||
'need_judiciary',
|
||||
'operator_description',
|
||||
'supervisor_name',
|
||||
'supervisor_id'
|
||||
];
|
||||
|
||||
public $table = "safety_and_privacy";
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -2,123 +2,117 @@
|
||||
|
||||
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;
|
||||
|
||||
public function dataTable(Request $request, $loadRelations = false)
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function operatorDataTable(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
$fields = ['id','lat','lon','province_id','province_fa','city_id','city_fa','edare_shahri_id','edare_shahri_name',
|
||||
'recognize_picture','action_picture','operator_id','operator_name','way_id','created_at','updated_at','step',
|
||||
'info_id','info_fa','activity_date_time', 'action_picture_document_upload_date', 'judiciary_document_upload_date',
|
||||
'step_fa', 'axis_type_id', 'axis_type_name'
|
||||
$fields = [
|
||||
'id','lat','lon', 'recognize_picture','action_picture','created_at','step', 'final_description',
|
||||
'info_fa', 'activity_date_time', 'action_picture_document_upload_date', 'judiciary_document_upload_date',
|
||||
'step_fa', 'axis_type_id', 'axis_type_name', 'action_date', 'is_finished', 'status_fa', 'supervisor_description', 'operator_description'
|
||||
];
|
||||
|
||||
if ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable')) {
|
||||
$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->edarate_shahri_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('اداره ای برای شما در سامانه ثبت نشده است!');
|
||||
}
|
||||
$query = SafetyAndPrivacy::query()->where('edare_shahri_id', '=', $user->edarate_shahri_id);
|
||||
|
||||
$query = SafetyAndPrivacy::query()->where('edare_shahri_id', '=', $user->edarate_shahri_id);
|
||||
return DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
allowedSelects: $fields
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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: ['*']
|
||||
allowedSortings: ['*'],
|
||||
allowedSelects: $fields
|
||||
);
|
||||
}
|
||||
|
||||
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) {
|
||||
foreach ($country['data'] as $key => $value) {
|
||||
$countryTotalSum += $value->qty;
|
||||
$countryData[$value->info_id][$value->step] = $value->qty;
|
||||
$countryData["sum"] = $countryTotalSum;
|
||||
}
|
||||
|
||||
$activities[] = (object) $countryData;
|
||||
$provinceQuery = SafetyAndPrivacy::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['data'] 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,92 +123,53 @@ 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 = SafetyAndPrivacy::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) {
|
||||
foreach ($province['data'] as $key => $value) {
|
||||
$provinceTotalSum += $value->qty;
|
||||
$provinceData["sum"] = $provinceTotalSum;
|
||||
$provinceData[$value->info_id][$value->step] = $value->qty;
|
||||
}
|
||||
$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['data'] 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 +184,6 @@ class SafetyAndPrivacyTableService
|
||||
$activities[$cityId]->sum += $value->qty;
|
||||
}
|
||||
|
||||
$activities = array_values($activities);
|
||||
|
||||
return [
|
||||
'activities' => $activities,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate,
|
||||
];
|
||||
return array_values($activities);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -73,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();
|
||||
|
||||
@@ -88,7 +96,7 @@ class DataTableService
|
||||
foreach ($sorting as $sort){
|
||||
$query = (new ApplySort($query, $sort))->apply();
|
||||
}
|
||||
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
@@ -101,6 +109,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)) {
|
||||
|
||||
@@ -33,7 +33,7 @@ class NikarayanService
|
||||
|
||||
$soapClient = new SoapClient($url);
|
||||
$result = $soapClient->UpdateInfo_RoadObservedProblems($array);
|
||||
Log::channel('nikarayan')->info($result);
|
||||
Log::channel('nikarayan')->info(json_encode($result));
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -49,15 +49,14 @@ class NikarayanService
|
||||
/**
|
||||
* @throws SoapFault
|
||||
*/
|
||||
public function getRoadObservedProblemsByDate()
|
||||
public function getRoadObservedProblemsByDate($time)
|
||||
{
|
||||
try {
|
||||
$url = "https://riws.rmto.ir/WebServices/NRPTrafficStatus.asmx?wsdl";
|
||||
|
||||
$v = verta();
|
||||
$month = $v->month < 10 ? '0' . $v->month : $v->month;
|
||||
$day = $v->day < 10 ? '0' . $v->day : $v->day;
|
||||
$date = $v->year . $month . $day;
|
||||
$month = $time->month < 10 ? '0' . $time->month : $time->month;
|
||||
$day = $time->day < 10 ? '0' . $time->day : $time->day;
|
||||
$date = $time->year . $month . $day;
|
||||
|
||||
$soap_client = new SoapClient($url);
|
||||
return $soap_client->Get_RoadObservedProblems_ByDate(array(
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
||||
@@ -18,7 +19,16 @@ class RoadItemsProjectFactory extends Factory
|
||||
{
|
||||
return [
|
||||
'item' => $this->faker->numberBetween(1, 10),
|
||||
'sub_item' => $this->faker->numberBetween(1, 10),
|
||||
];
|
||||
'sub_items' => $this->faker->title(),
|
||||
'start_lat' =>$this->faker->latitude(),
|
||||
'start_lng' =>$this->faker->longitude(),
|
||||
'is_new' => $this->faker->boolean(),
|
||||
'status' => $this->faker->randomElement([0, 1, 2]),
|
||||
'activity_date_time' =>$this->faker->dateTimeBetween('-1 year', 'now'),
|
||||
'province_id' => $this->faker->numberBetween(1, 10),
|
||||
'city_id' => $this->faker->numberBetween(1, 10),
|
||||
'user_id' =>$this->faker->numberBetween(1, 10),
|
||||
'user_name' => $this->faker->name(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('safety_and_privacy', function (Blueprint $table) {
|
||||
$table->dateTime('action_date')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('safety_and_privacy', function (Blueprint $table) {
|
||||
$table->dropColumn('action_date');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('rahdari_point_histories', function (Blueprint $table) {
|
||||
$table->after('user_id', function (Blueprint $table) {
|
||||
$table->unsignedSmallInteger('previous_province_id')->nullable();
|
||||
$table->string('previous_province_name')->nullable();
|
||||
$table->unsignedSmallInteger('previous_city_id')->nullable();
|
||||
$table->string('previous_city_name')->nullable();
|
||||
$table->string('previous_name')->nullable();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('rahdari_point_histories', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'previous_province_id',
|
||||
'previous_province_name',
|
||||
'previous_city_id',
|
||||
'previous_city_name',
|
||||
'previous_name',
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('safety_and_privacy', function (Blueprint $table) {
|
||||
$table->boolean('is_finished')->nullable();
|
||||
$table->integer('status')->nullable();
|
||||
$table->string('status_fa')->nullable();
|
||||
$table->string('operator_description')->nullable();
|
||||
$table->string('supervisor_description')->nullable();
|
||||
$table->string('final_description')->nullable();
|
||||
$table->boolean('need_judiciary')->nullable();
|
||||
$table->integer('supervisor_id')->nullable();
|
||||
$table->string('supervisor_name')->nullable();
|
||||
$table->text('judiciary_document')->nullable()->change();
|
||||
$table->dateTime('judiciary_document_upload_date')->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('safety_and_privacy', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'status', 'final_description', 'is_finished',
|
||||
'supervisor_description', 'status_fa', 'need_judiciary',
|
||||
'operator_description', 'supervisor_name', 'supervisor_id',
|
||||
]);
|
||||
$table->text('judiciary_document')->change();
|
||||
$table->dateTime('judiciary_document_upload_date')->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -97,7 +97,7 @@
|
||||
<td style="border: 1px solid black;text-align: center;">
|
||||
{{ $item['sub_item_data'] ? ($item['unit_fa'] ? $item['sub_item_data'] . '(' . $item['unit_fa'] . ')' : $item['sub_item_data'] . '(-)') : '-' }}
|
||||
</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['cmms_machines'] != null ? $item['cmms_machines']->pluck('machine_code')->implode(', ') : '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['cmmsMachines'] != null ? $item['cmmsMachines']->pluck('machine_code')->implode(', ') : '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['rahdaran'] != null ? $item['rahdaran']->pluck('code')->implode(', ') : '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">
|
||||
{{ isset($item['start_lat']) && isset($item['start_lng']) ? $item['start_lat'] . ' ' . $item['start_lng'] : '-' }}
|
||||
@@ -114,5 +114,4 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
<td style="border: 1px solid black;text-align: center;">
|
||||
{{ $item['sub_item_data'] ? ($item['unit_fa'] ? $item['sub_item_data'] . '(' . $item['unit_fa'] . ')' : $item['sub_item_data'] . '(-)') : '-' }}
|
||||
</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['cmms_machines'] != null ? $item['cmms_machines']->pluck('machine_code')->implode(', ') : '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['cmmsMachines'] != null ? $item['cmmsMachines']->pluck('machine_code')->implode(', ') : '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['rahdaran'] != null ? $item['rahdaran']->pluck('code')->implode(', ') : '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">
|
||||
{{ isset($item['start_lat']) && isset($item['start_lng']) ? $item['start_lat'] . ' ' . $item['start_lng'] : '-' }}
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['id'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['province_fa'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['edare_name'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['cmms_machines'] != null ? $item['cmms_machines']->pluck('machine_code')->implode(', ') : '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['cmmsMachines'] != null ? $item['cmmsMachines']->pluck('machine_code')->implode(', ') : '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['rahdaran'] != null ? $item['rahdaran']->pluck('code')->implode(', ') : '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['start_time'] ? verta($item['start_time'])->format('Y/n/j H:i:s') : '-' }}
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['end_time'] ? verta($item['end_time'])->format('Y/n/j H:i:s') : '-' }}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="9"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13;">
|
||||
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
|
||||
گزارش کارتابل ارزیابی گشت راهداری
|
||||
</th>
|
||||
</tr>
|
||||
@@ -74,7 +74,7 @@
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['id'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['province_fa'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['edare_name'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['cmms_machines'] != null ? $item['cmms_machines']->pluck('machine_code')->implode(', ') : '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['cmmsMachines'] != null ? $item['cmmsMachines']->pluck('machine_code')->implode(', ') : '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['rahdaran'] != null ? $item['rahdaran']->pluck('code')->implode(', ') : '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['start_time'] ? verta($item['start_time'])->format('Y/n/j H:i:s') : '-' }}
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['end_time'] ? verta($item['end_time'])->format('Y/n/j H:i:s') : '-' }}
|
||||
|
||||
@@ -28,12 +28,7 @@
|
||||
<tr>
|
||||
<th colspan="11"
|
||||
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') }}
|
||||
|
||||
گزارش نگهداری حریم راه
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>فعالیت های نگهداری حریم راه</title>
|
||||
|
||||
<style>
|
||||
table,
|
||||
th,
|
||||
td {
|
||||
border: 1px solid black;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body dir="rtl" style="text-align: center;">
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<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="10"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="10"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
|
||||
گزارش فعالیت های نگهداری حریم راه
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<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;">
|
||||
مورد مشاهده شده
|
||||
</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;">
|
||||
تاریخ ثبت
|
||||
</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;">
|
||||
تاریخ بارگذاری مستندات قضایی
|
||||
</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;">
|
||||
وضعیت
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach ($data as $item)
|
||||
<tr>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['id'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['info_fa'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['axis_type_name'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['created_at'] ? verta($item['created_at'])->format('Y/n/j H:i:s') : '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['activity_date_time'] ? verta($item['activity_date_time'])->format('Y/n/j H:i:s') : '-' }}</td>
|
||||
|
||||
<td style="border: 1px solid black;text-align: center;">
|
||||
{{ $item['judiciary_document_upload_date'] && $item['judiciary_document_upload_date'] != '0000-00-00 00:00:00' ? verta($item['judiciary_document_upload_date'])->format('Y/n/j H:i:s') : '-' }}
|
||||
</td>
|
||||
|
||||
<td style="border: 1px solid black;text-align: center;">
|
||||
{{ $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>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@@ -27,13 +27,8 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="11"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13;">
|
||||
گزارش نگهداری حریم راه از تاریخ
|
||||
{{ verta($fromDate)->format('Y/n/j') }}
|
||||
تا
|
||||
تاریخ
|
||||
{{ verta($toDate)->format('Y/n/j') }}
|
||||
|
||||
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
|
||||
گزارش نگهداری حریم راه
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -52,7 +52,15 @@
|
||||
</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;">
|
||||
نوع محور
|
||||
</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;">
|
||||
@@ -60,7 +68,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;">
|
||||
@@ -70,10 +78,6 @@
|
||||
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;">
|
||||
تاریخ ثبت
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -84,6 +88,8 @@
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['province_fa'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['edare_shahri_name'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['info_fa'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['axis_type_name'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['created_at'] ? verta($item['created_at'])->format('Y/n/j H:i:s') : '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['activity_date_time'] ? verta($item['activity_date_time'])->format('Y/n/j H:i:s') : '-' }}</td>
|
||||
|
||||
<td style="border: 1px solid black;text-align: center;">
|
||||
@@ -91,11 +97,10 @@
|
||||
</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>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['created_at'] ? verta($item['created_at'])->format('Y/n/j H:i:s') : '-' }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
@@ -10,6 +10,7 @@ use App\Http\Controllers\V3\Dashboard\ItemsManagementController;
|
||||
use App\Http\Controllers\V3\Dashboard\ObservedItemController;
|
||||
use App\Http\Controllers\V3\Dashboard\AccidentReceiptController;
|
||||
use App\Http\Controllers\V3\Dashboard\OtpManagementController;
|
||||
use App\Http\Controllers\V3\Dashboard\RoadMaintenanceStationController;
|
||||
use App\Http\Controllers\V3\Dashboard\Reports\AccidentReceiptReportController;
|
||||
use App\Http\Controllers\V3\Dashboard\Reports\RoadItemsReportController;
|
||||
use App\Http\Controllers\V3\Dashboard\Reports\RoadPatrolReportController;
|
||||
@@ -17,7 +18,10 @@ use App\Http\Controllers\V3\Dashboard\Reports\SafetyAndPrivacyReportController;
|
||||
use App\Http\Controllers\V3\Dashboard\RoadItemsProjectController;
|
||||
use App\Http\Controllers\V3\Dashboard\RoadObservationController;
|
||||
use App\Http\Controllers\V3\Dashboard\RoadPatrolProjectController;
|
||||
use App\Http\Controllers\V3\Dashboard\SafetyAndPrivacyController;
|
||||
use App\Http\Controllers\V3\Dashboard\SafetyAndPrivacy\OperatorController;
|
||||
use App\Http\Controllers\V3\Dashboard\SafetyAndPrivacy\OperatorReportController;
|
||||
use App\Http\Controllers\V3\Dashboard\SafetyAndPrivacy\SupervisorController;
|
||||
use App\Http\Controllers\V3\Dashboard\SafetyAndPrivacy\SupervisorReportController;
|
||||
use App\Http\Controllers\V3\FMSVehicleManagementController;
|
||||
use App\Http\Controllers\V3\Harim\DivarkeshiController;
|
||||
use App\Http\Controllers\V3\LogListManagementController;
|
||||
@@ -321,6 +325,7 @@ Route::prefix('road_observations')
|
||||
|
||||
Route::prefix('log_list')
|
||||
->name('logList.')
|
||||
->middleware('permission:manage-log-list')
|
||||
->controller(LogListManagementController::class)
|
||||
->group(function () {
|
||||
Route::get('/', 'index')->name('index');
|
||||
@@ -333,27 +338,58 @@ Route::prefix('log_list')
|
||||
|
||||
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('/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('permission:add-safety-and-privacy');
|
||||
Route::get('/sub_items', 'subItems')->name('subItems');
|
||||
Route::post('/second_step_store/{safetyAndPrivacy}', 'secondStepStore')->name('secondStepStore')->middleware('permission:add-safety-and-privacy');
|
||||
Route::post('/third_step_store/{safetyAndPrivacy}', 'thirdStepStore')->name('thirdStepStore')->middleware('permission:add-safety-and-privacy');
|
||||
Route::get('/{safetyAndPrivacy}', 'show')->name('show');
|
||||
Route::delete('/{safetyAndPrivacy}', 'destroy')->name('destroy')->middleware('permission:delete-safety-and-privacy');
|
||||
Route::get('/deserialize/{safetyAndPrivacy}', 'deserialize')->name('deserialize');
|
||||
Route::name('operator.')
|
||||
->controller(OperatorController::class)
|
||||
->group(function () {
|
||||
Route::get('operator', 'index')->name('index')
|
||||
->middleware('permission:show-safety-and-privacy-operator-cartable-edarate-shahri');
|
||||
Route::get('operator/excel_report', 'excelReport')->name('excelReport')
|
||||
->middleware('permission:show-safety-and-privacy-operator-cartable-edarate-shahri');
|
||||
Route::post('operator/first_step_store', 'firstStepStore')->name('firstStepStore')->middleware(['validate-store-access', 'permission:add-safety-and-privacy']);
|
||||
Route::get('/sub_items', 'subItems')->name('subItems');
|
||||
Route::get('/map', 'map')->name('map');
|
||||
Route::post('operator/second_step_store/{safetyAndPrivacy}', 'secondStepStore')->name('secondStepStore')->middleware(['validate-store-access','permission:add-safety-and-privacy']);
|
||||
Route::post('operator/third_step_store/{safetyAndPrivacy}', 'thirdStepStore')->name('thirdStepStore')->middleware(['validate-store-access','permission:add-safety-and-privacy']);
|
||||
Route::post('operator/{safetyAndPrivacy}', 'update')->name('update')->middleware('permission:update-safety-and-privacy');
|
||||
Route::get('operator/{safetyAndPrivacy}', 'show')->name('show');
|
||||
Route::delete('operator/{safetyAndPrivacy}', 'destroy')->name('destroy')->middleware('permission:delete-safety-and-privacy');
|
||||
Route::get('/deserialize/{safetyAndPrivacy}', 'deserialize')->name('deserialize');
|
||||
Route::post('operator/finish/{safetyAndPrivacy}', 'finish')->name('finish');
|
||||
});
|
||||
|
||||
Route::prefix('supervisor')
|
||||
->name('supervisor.')
|
||||
->controller(SupervisorController::class)
|
||||
->group(function () {
|
||||
Route::get('/', 'index')->name('index')
|
||||
->middleware('permission:show-safety-and-privacy-operator-cartable|show-safety-and-privacy-operator-cartable-province');
|
||||
Route::get('/excel_report', 'excelReport')->name('excelReport')
|
||||
->middleware('permission:show-safety-and-privacy-operator-cartable|show-safety-and-privacy-operator-cartable-province');
|
||||
Route::post('/confirm/{safetyAndPrivacy}', 'confirm')->name('confirm');
|
||||
Route::post('/reject/{safetyAndPrivacy}', 'reject')->name('reject');
|
||||
});
|
||||
});
|
||||
|
||||
Route::prefix('safety_and_privacy_report')
|
||||
->name('SafetyAndPrivacyReport.')
|
||||
->controller(SafetyAndPrivacyReportController::class)
|
||||
->group(function () {
|
||||
Route::get('/country_activity', 'countryActivity')->name('countryActivity');
|
||||
Route::get('/province_activity', 'provinceActivity')->name('provinceActivity');
|
||||
Route::get('/country_excel_activity', 'countryExcelActivity')->name('countryExcelActivity');
|
||||
Route::get('/province_excel_activity', 'provinceExcelActivity')->name('provinceExcelActivity');
|
||||
Route::prefix('operator')
|
||||
->name('operator.')
|
||||
->controller(OperatorReportController::class)
|
||||
->group(function () {
|
||||
Route::get('/country_activity', 'countryActivity')->name('countryActivity');
|
||||
Route::get('/province_activity', 'provinceActivity')->name('provinceActivity');
|
||||
Route::get('/country_excel_activity', 'countryExcelActivity')->name('countryExcelActivity');
|
||||
Route::get('/province_excel_activity', 'provinceExcelActivity')->name('provinceExcelActivity');
|
||||
});
|
||||
|
||||
Route::prefix('supervisor')
|
||||
->name('supervisor.')
|
||||
->controller(SupervisorReportController::class)
|
||||
->group(function () {
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Route::prefix('otp')
|
||||
@@ -372,6 +408,7 @@ Route::name('items.')
|
||||
|
||||
Route::prefix('permissions')
|
||||
->name('permissions.')
|
||||
->middleware('permission:manage-permissions')
|
||||
->controller(PermissionManagementController::class)
|
||||
->group(function () {
|
||||
Route::get('/', 'index')->name('index');
|
||||
@@ -382,3 +419,16 @@ Route::prefix('permissions')
|
||||
});
|
||||
|
||||
Route::get('/notifications', NotificationController::class)->name('notifications');
|
||||
|
||||
Route::prefix('road_maintenance_station')
|
||||
->name('roadMaintenanceStation.')
|
||||
->controller( RoadMaintenanceStationController::class)
|
||||
->group(function () {
|
||||
Route::get('/', 'index')->name('index')->middleware('permission:show-tollhouse|show-tollhouse-province');
|
||||
Route::post('/', 'store')->name('store');
|
||||
Route::get('/map', 'map')->name('map');
|
||||
Route::get('/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');
|
||||
});
|
||||
|
||||
59
tests/Feature/V3/Permission/IndexTest.php
Normal file
59
tests/Feature/V3/Permission/IndexTest.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\V3\Permission;
|
||||
|
||||
use App\Models\Permission;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class IndexTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase, WithFaker;
|
||||
/**
|
||||
* A basic feature test example.
|
||||
*/
|
||||
public function test_user_should_have_manage_permission(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->getJson(route('v3.permissions.index'));
|
||||
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_all_permissions_returned_successfully(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'manage-permissions'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->getJson(route('v3.permissions.index', [
|
||||
'start' => 0,
|
||||
'size' => 10,
|
||||
'filters' => json_encode([]),
|
||||
'sorting' => json_encode([]),
|
||||
]));
|
||||
|
||||
$response->assertOk();
|
||||
|
||||
$response->assertJsonStructure([
|
||||
'data' => [
|
||||
'*' => [
|
||||
'id',
|
||||
'name',
|
||||
'name_fa',
|
||||
'type',
|
||||
'type_fa',
|
||||
'description',
|
||||
],
|
||||
],
|
||||
"meta" => [
|
||||
"totalRowCount"
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
297
tests/Feature/V3/Permission/StoreTest.php
Normal file
297
tests/Feature/V3/Permission/StoreTest.php
Normal file
@@ -0,0 +1,297 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\V3\Permission;
|
||||
|
||||
use App\Models\Permission;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class StoreTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase, WithFaker;
|
||||
/**
|
||||
* A basic feature test example.
|
||||
*/
|
||||
public function test_user_should_have_manage_permission(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.permissions.store'));
|
||||
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_name_attribute_is_required(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'manage-permissions'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.permissions.store'));
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'name' => __('validation.required', ['attribute' => 'نام'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_name_attribute_should_be_string(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'manage-permissions'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.permissions.store'), [
|
||||
'name' => $this->faker->numberBetween(1, 10)
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'name' => __('validation.string', ['attribute' => 'نام'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_name_attribute_should_be_unique(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'manage-permissions'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$permission = Permission::factory()->create([
|
||||
'name' => $this->faker->name()
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.permissions.store'), [
|
||||
'name' => $permission->name,
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'name' => __('validation.unique', ['attribute' => 'نام'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_name_fa_attribute_is_required(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'manage-permissions'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.permissions.store'));
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'name_fa' => __('validation.required', ['attribute' => 'name fa'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_name_fa_attribute_should_be_string(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'manage-permissions'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.permissions.store'), [
|
||||
'name_fa' => $this->faker->numberBetween(1, 10)
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'name_fa' => __('validation.string', ['attribute' => 'name fa'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_description_attribute_should_be_string(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'manage-permissions'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.permissions.store'), [
|
||||
'description' => $this->faker->numberBetween(1, 10)
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'description' => __('validation.string', ['attribute' => 'توضیحات'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_type_attribute_is_required(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'manage-permissions'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.permissions.store'));
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'type' => __('validation.required', ['attribute' => 'type'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_type_attribute_should_be_string(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'manage-permissions'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.permissions.store'), [
|
||||
'type' => $this->faker->numberBetween(1, 10)
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'type' => __('validation.string', ['attribute' => 'type'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_type_fa_attribute_is_required(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'manage-permissions'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.permissions.store'));
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'type_fa' => __('validation.required', ['attribute' => 'type fa'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_type_fa_attribute_should_be_string(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'manage-permissions'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.permissions.store'), [
|
||||
'type_fa' => $this->faker->numberBetween(1, 10)
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'type_fa' => __('validation.string', ['attribute' => 'type fa'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_need_province_attribute_is_required(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'manage-permissions'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.permissions.store'));
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'need_province' => __('validation.required', ['attribute' => 'need province'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_need_province_attribute_should_be_1_or_0(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'manage-permissions'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.permissions.store'), [
|
||||
'need_province' => $this->faker->numberBetween(3, 9),
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'need_province' => __('validation.in', ['attribute' => 'need province'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_need_edare_shahri_attribute_is_required(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'manage-permissions'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.permissions.store'));
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'need_edare_shahri' => __('validation.required', ['attribute' => 'need edare shahri'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_need_edare_shahri_attribute_should_be_1_or_0(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'manage-permissions'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.permissions.store'), [
|
||||
'need_edare_shahri' => $this->faker->numberBetween(3, 9),
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'need_edare_shahri' => __('validation.in', ['attribute' => 'need edare shahri'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_user_can_create_a_permission()
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'manage-permissions'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$inputData = [
|
||||
'name' => $this->faker->name(),
|
||||
'name_fa' => $this->faker->name(),
|
||||
'description' => $this->faker->lexify(),
|
||||
'type' => $this->faker->name(),
|
||||
'type_fa' => $this->faker->name(),
|
||||
'need_province' => $this->faker->numberBetween(0, 1),
|
||||
'need_edare_shahri' => $this->faker->numberBetween(0, 1),
|
||||
];
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.permissions.store'), $inputData);
|
||||
|
||||
$response->assertOk()
|
||||
->assertExactJson([
|
||||
'message' => __('messages.successful'),
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('permissions', $inputData);
|
||||
}
|
||||
}
|
||||
57
tests/Feature/V3/RoadItemsProject/DeleteTest.php
Normal file
57
tests/Feature/V3/RoadItemsProject/DeleteTest.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\V3\RoadItemsProject;
|
||||
|
||||
use App\Models\LogList;
|
||||
use App\Models\Permission;
|
||||
use App\Models\RoadItemsProject;
|
||||
use App\Models\User;
|
||||
use App\Models\UserActivityLog;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DeleteTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase, WithFaker;
|
||||
|
||||
public function test_user_should_have_show_road_item_supervise_delete_permission(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$roadItem = RoadItemsProject::factory()->create();
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.delete', [$roadItem->id]));
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_user_cannot_access_authentication_delete(): void
|
||||
{
|
||||
$roadItem = RoadItemsProject::factory()->create();
|
||||
$response =$this->postJson(route('v3.road_items.delete', [$roadItem->id]));
|
||||
$response->assertStatus(401);
|
||||
|
||||
}
|
||||
|
||||
public function test_user_can_delete_road_item(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'delete-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$logList = LogList::factory()->create([
|
||||
'log_unique_code' => 1151,
|
||||
]);
|
||||
UserActivityLog::factory()->create();
|
||||
$roadItem = RoadItemsProject::factory()->create();
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.delete', [$roadItem->id]));
|
||||
|
||||
$response->assertOk()
|
||||
->assertJson([
|
||||
'message' => __('messages.successful'),
|
||||
]);
|
||||
$this->assertDatabaseMissing('road_items_projects', [
|
||||
'id' => $roadItem->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,14 @@ class OperatorIndexTest extends TestCase
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_user_cannot_access_authentication_to_operator_index(): void
|
||||
{
|
||||
$response = $this->getJson(route('v3.road_items.operatorIndex'));
|
||||
|
||||
$response->assertStatus(401);
|
||||
}
|
||||
|
||||
|
||||
public function test_operator_can_see_the_data_table(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
|
||||
72
tests/Feature/V3/RoadItemsProject/RestoreTest.php
Normal file
72
tests/Feature/V3/RoadItemsProject/RestoreTest.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\V3\RoadItemsProject;
|
||||
|
||||
use App\Models\LogList;
|
||||
use App\Models\Permission;
|
||||
use App\Models\RoadItemsProject;
|
||||
use App\Models\User;
|
||||
use App\Models\UserActivityLog;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
use function Ramsey\Uuid\v3;
|
||||
|
||||
class RestoreTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase, WithFaker;
|
||||
|
||||
public function test_user_should_have_show_road_item_supervise_restore_permission(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$roadItem = RoadItemsProject::factory()->create();
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.restore', [$roadItem->id]));
|
||||
$response->assertForbidden();
|
||||
}
|
||||
public function test_user_cannot_access_authentication_restore(): void
|
||||
{
|
||||
$roadItem = RoadItemsProject::factory()->create();
|
||||
$response =$this->postJson(route('v3.road_items.restore', [$roadItem->id]));
|
||||
$response->assertStatus(401);
|
||||
|
||||
}
|
||||
public function test_user_can_restore_road_item(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'restore-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$logList = LogList::factory()->create([
|
||||
'log_unique_code' => 1150,
|
||||
]);
|
||||
UserActivityLog::factory()->create();
|
||||
|
||||
$roadItem = RoadItemsProject::factory()->create([
|
||||
'status' => 1,
|
||||
'status_fa' => 'تایید شده',
|
||||
'supervisor_id' => $user->id,
|
||||
'supervisor_name' => $user->name,
|
||||
'supervisor_description' => 'تایید شده توسط تست',
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.restore', [$roadItem->id]));
|
||||
|
||||
$response->assertOk()
|
||||
->assertJson([
|
||||
'message' => __('messages.successful'),
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('road_items_projects', [
|
||||
'id' => $roadItem->id,
|
||||
'status' => 0,
|
||||
'status_fa' => 'در حال بررسی',
|
||||
'supervisor_id' => null,
|
||||
'supervisor_name' => null,
|
||||
'supervisor_description' => null,
|
||||
'supervising_time' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ use App\Models\ObservedItem;
|
||||
use App\Models\Permission;
|
||||
use App\Models\Province;
|
||||
use App\Models\Rahdaran;
|
||||
use App\Models\RoadItemsProject;
|
||||
use App\Models\User;
|
||||
use App\Models\UserActivityLog;
|
||||
use App\Services\NominatimService;
|
||||
@@ -22,6 +23,8 @@ use Illuminate\Support\Facades\Storage;
|
||||
use Mockery\MockInterface;
|
||||
use Symfony\Component\Finder\Exception\AccessDeniedException;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
|
||||
class StoreTest extends TestCase
|
||||
{
|
||||
@@ -37,104 +40,56 @@ class StoreTest extends TestCase
|
||||
|
||||
$response->assertForbidden();
|
||||
}
|
||||
public function test_user_cannot_access_authentication_store(): void
|
||||
{
|
||||
// $roadItem = RoadItemsProject::factory()->create();
|
||||
$response =$this->postJson(route('v3.road_items.store'));
|
||||
$response->assertStatus(401);
|
||||
|
||||
public function test_start_point_is_required(): void
|
||||
}
|
||||
|
||||
public function test_required_fields(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'));
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'start_point' => __('validation.required', ['attribute' => 'start point'])
|
||||
'start_point' => __('validation.required', ['attribute' => 'start point']),
|
||||
'item_id' => __('validation.required', ['attribute' => 'item id']),
|
||||
'sub_item_id' => __('validation.required', ['attribute' => 'sub item id']),
|
||||
'amount' => __('validation.required', ['attribute' => 'amount']),
|
||||
'activity_date' => __('validation.required', ['attribute' => 'تاریخ فعالیت']),
|
||||
'activity_time' => __('validation.required', ['attribute' => 'ساعت فعالیت']),
|
||||
'machines_id' => __('validation.required', ['attribute' => 'machines id']),
|
||||
'rahdaran_id' => __('validation.required', ['attribute' => 'rahdaran id']),
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_item_id_is_required(): void
|
||||
public function test_integer_fields(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create();
|
||||
$data = [
|
||||
'item_id' => $this->faker->name,
|
||||
'sub_item_id' => $this->faker->name,
|
||||
'observed_item_id' => $this->faker->name,
|
||||
];
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'));
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), $data);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'item_id' => __('validation.required', ['attribute' => 'item id'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_item_id_should_be_integer(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), [
|
||||
'item_id' => $this->faker->name
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'item_id' => __('validation.integer', ['attribute' => 'item id'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_sub_item_id_is_required(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'));
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'sub_item_id' => __('validation.required', ['attribute' => 'sub item id'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_sub_item_id_should_be_integer(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), [
|
||||
'sub_item_id' => $this->faker->name
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'sub_item_id' => __('validation.integer', ['attribute' => 'sub item id'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_amount_is_required(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'));
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'amount' => __('validation.required', ['attribute' => 'amount'])
|
||||
'item_id' => __('validation.integer', ['attribute' => 'item id']),
|
||||
'sub_item_id' => __('validation.integer', ['attribute' => 'sub item id']),
|
||||
'observed_item_id' => __('validation.integer', ['attribute' => 'observed item id']),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -156,7 +111,7 @@ class StoreTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_observed_item_id_should_be_integer(): void
|
||||
public function test_exists_fields(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
@@ -164,523 +119,362 @@ class StoreTest extends TestCase
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), [
|
||||
'observed_item_id' => $this->faker->name
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'observed_item_id' => __('validation.integer', ['attribute' => 'observed item id'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_observed_item_id_should_be_existed_in_db(): void
|
||||
{
|
||||
$observedItem = ObservedItem::factory()->create();
|
||||
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), [
|
||||
'observed_item_id' => $this->faker->numberBetween(10, 20)
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'observed_item_id' => __('validation.exists', ['attribute' => 'observed item id'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_activity_date_is_required(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'));
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'activity_date' => __('validation.required', ['attribute' => 'تاریخ فعالیت'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_activity_date_should_match_the_format(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), [
|
||||
'activity_date' => $this->faker->date('d-m-Y-H-i-s')
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'activity_date' => __('validation.date_format', ['attribute' => 'تاریخ فعالیت', 'format' => 'Y-m-d'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_activity_time_is_required(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'));
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'activity_time' => __('validation.required', ['attribute' => 'ساعت فعالیت'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_activity_time_should_match_the_format(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), [
|
||||
'activity_time' => $this->faker->date('d-m-Y-H-i-s')
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'activity_time' => __('validation.date_format', ['attribute' => 'ساعت فعالیت', 'format' => 'H:i'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_before_image_should_be_image(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), [
|
||||
'before_image' => $this->faker->name
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'before_image' => __('validation.image', ['attribute' => 'before image'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_before_image_should_be_less_than_4096kb(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$image = UploadedFile::fake()->create('image.jpg', 5096);
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), [
|
||||
'before_image' => $image
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'before_image' => __('validation.max.file', ['attribute' => 'before image', 'max' => 4096])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_after_image_should_be_image(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), [
|
||||
'after_image' => $this->faker->randomNumber()
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'after_image' => __('validation.image', ['attribute' => 'after image'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_after_image_should_be_less_than_4096kb(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$image = UploadedFile::fake()->create('image.jpg', 5096);
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), [
|
||||
'after_image' => $image
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'after_image' => __('validation.max.file', ['attribute' => 'after image', 'max' => 4096])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_cmms_machine_id_is_required(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'));
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'cmms_machine_id' => __('validation.required', ['attribute' => 'کد یکتا ماشین'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_cmms_machine_id_should_already_exists_on_the_table(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), [
|
||||
'cmms_machine_id' => $this->faker->numberBetween(10, 100)
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'cmms_machine_id' => __('validation.exists', ['attribute' => 'کد یکتا ماشین'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_rahdar_id_is_required(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'));
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'rahdar_id' => __('validation.required', ['attribute' => 'rahdar id'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_rahdar_id_should_already_exists_on_the_table(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), [
|
||||
'rahdar_id' => $this->faker->numberBetween(10, 100)
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'rahdar_id' => __('validation.exists', ['attribute' => 'rahdar id'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_province_user_is_prohibited_to_access(): void
|
||||
{
|
||||
$edarateOstani = EdarateOstani::factory()->create();
|
||||
$cmmsMachine = CMMSMachine::factory()->create();
|
||||
$rahdar = Rahdaran::factory()->create();
|
||||
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create([
|
||||
'edarate_ostani_id' => $edarateOstani->id
|
||||
]);
|
||||
|
||||
$data = [
|
||||
'start_point' => '12,12',
|
||||
'item_id' => $this->faker->numberBetween(1, 10),
|
||||
'sub_item_id' => $this->faker->numberBetween(1, 10),
|
||||
'amount' => $this->faker->numberBetween(1, 10),
|
||||
'activity_date' => $this->faker->date(),
|
||||
'activity_time' => $this->faker->date('H:i'),
|
||||
'before_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
'after_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
'cmms_machine_id' => $cmmsMachine->id,
|
||||
'rahdar_id' => $rahdar->id,
|
||||
'machines_id' => [$this->faker->numberBetween(10000, 99999)],
|
||||
'rahdaran_id' => [$this->faker->numberBetween(10000, 99999)],
|
||||
'observed_item_id' => $this->faker->numberBetween(10000, 99999),
|
||||
];
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), $data);
|
||||
|
||||
$response->assertStatus(400)
|
||||
->assertExactJson([
|
||||
'message' => 'امکان ثبت فعالیت برای ادارات استانی و ستادی وجود ندارد!'
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'machines_id.0',
|
||||
'rahdaran_id.0',
|
||||
'observed_item_id',
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_user_should_have_edarate_shahri_id(): void
|
||||
public function test_image_fields(): void
|
||||
{
|
||||
$city = City::factory()->create();
|
||||
$cmmsMachine = CMMSMachine::factory()->create();
|
||||
$rahdar = Rahdaran::factory()->create();
|
||||
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create([
|
||||
'city_id' => $city->id
|
||||
]);
|
||||
'name' => 'create-road-item']))
|
||||
->create();
|
||||
|
||||
$data = [
|
||||
'start_point' => '12,12',
|
||||
'item_id' => $this->faker->numberBetween(1, 10),
|
||||
'sub_item_id' => $this->faker->numberBetween(1, 10),
|
||||
'amount' => $this->faker->numberBetween(1, 10),
|
||||
'activity_date' => $this->faker->date(),
|
||||
'activity_time' => $this->faker->date('H:i'),
|
||||
'before_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
'after_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
'cmms_machine_id' => $cmmsMachine->id,
|
||||
'rahdar_id' => $rahdar->id,
|
||||
'before_image' =>$this->faker->name,
|
||||
'after_image' =>$this->faker->name,
|
||||
];
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), $data);
|
||||
|
||||
$response->assertStatus(400)
|
||||
->assertExactJson([
|
||||
'message' => 'اداره شهری برای شما در سامانه ثبت نشده است!'
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_end_point_required_when_info_item_needs_end_point(): void
|
||||
{
|
||||
$city = City::factory()->create();
|
||||
$edarateShari = EdarateShahri::factory()->create();
|
||||
$cmmsMachine = CMMSMachine::factory()->create();
|
||||
$rahdar = Rahdaran::factory()->create();
|
||||
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create([
|
||||
'city_id' => $city->id,
|
||||
'edarate_shahri_id' => $edarateShari->id
|
||||
]);
|
||||
|
||||
$data = [
|
||||
'start_point' => '12,12',
|
||||
'item_id' => $this->faker->numberBetween(1, 10),
|
||||
'sub_item_id' => $this->faker->numberBetween(1, 10),
|
||||
'amount' => $this->faker->numberBetween(1, 10),
|
||||
'activity_date' => $this->faker->date(),
|
||||
'activity_time' => $this->faker->date('H:i'),
|
||||
'before_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
'after_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
'cmms_machine_id' => $cmmsMachine->id,
|
||||
'rahdar_id' => $rahdar->id,
|
||||
];
|
||||
|
||||
InfoItem::factory()->create([
|
||||
'item' => $data['item_id'],
|
||||
'sub_item' => $data['sub_item_id'],
|
||||
'needs_end_point' => 1
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), $data);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'end_point' => __('validation.required', ['attribute' => 'end_point'])
|
||||
'before_image' => __('validation.image', ['attribute' => 'before image']),
|
||||
'after_image' => __('validation.image', ['attribute' => 'after image']),
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_before_image_required_when_info_item_needs_image(): void
|
||||
public function test_image_should_be_less_than_4096kb(): void
|
||||
{
|
||||
$city = City::factory()->create();
|
||||
$edarateShari = EdarateShahri::factory()->create();
|
||||
$cmmsMachine = CMMSMachine::factory()->create();
|
||||
$rahdar = Rahdaran::factory()->create();
|
||||
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create([
|
||||
'city_id' => $city->id,
|
||||
'edarate_shahri_id' => $edarateShari->id
|
||||
]);
|
||||
->create();
|
||||
|
||||
$data = [
|
||||
'start_point' => '12,12',
|
||||
'item_id' => $this->faker->numberBetween(1, 10),
|
||||
'sub_item_id' => $this->faker->numberBetween(1, 10),
|
||||
'amount' => $this->faker->numberBetween(1, 10),
|
||||
'activity_date' => $this->faker->date(),
|
||||
'activity_time' => $this->faker->date('H:i'),
|
||||
'cmms_machine_id' => $cmmsMachine->id,
|
||||
'rahdar_id' => $rahdar->id,
|
||||
'before_image' => UploadedFile::fake()->create('image.jpg', 5096),
|
||||
'after_image' => UploadedFile::fake()->create('image.jpg', 5096),
|
||||
];
|
||||
|
||||
InfoItem::factory()->create([
|
||||
'item' => $data['item_id'],
|
||||
'sub_item' => $data['sub_item_id'],
|
||||
'needs_image' => 1
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), $data);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'before_image' => __('validation.required', ['attribute' => 'before_image'])
|
||||
'before_image' => __('validation.max.file', ['attribute' => 'before image', 'max' => 4096]),
|
||||
'after_image' => __('validation.max.file', ['attribute' => 'after image', 'max' => 4096]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_after_image_required_when_info_item_needs_image(): void
|
||||
public function test_date_format_fields(): void
|
||||
{
|
||||
$city = City::factory()->create();
|
||||
$edarateShari = EdarateShahri::factory()->create();
|
||||
$cmmsMachine = CMMSMachine::factory()->create();
|
||||
$rahdar = Rahdaran::factory()->create();
|
||||
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create([
|
||||
'city_id' => $city->id,
|
||||
'edarate_shahri_id' => $edarateShari->id
|
||||
]);
|
||||
'name' => 'create-road-item']))
|
||||
->create();
|
||||
|
||||
$data = [
|
||||
'start_point' => '12,12',
|
||||
'item_id' => $this->faker->numberBetween(1, 10),
|
||||
'sub_item_id' => $this->faker->numberBetween(1, 10),
|
||||
'amount' => $this->faker->numberBetween(1, 10),
|
||||
'activity_date' => $this->faker->date(),
|
||||
'activity_time' => $this->faker->date('H:i'),
|
||||
'cmms_machine_id' => $cmmsMachine->id,
|
||||
'rahdar_id' => $rahdar->id,
|
||||
'activity_date' => $this->faker->date('d-m-Y-H-i-s'),
|
||||
'activity_time'=> $this->faker->date('d-m-Y-H-i-s'),
|
||||
];
|
||||
|
||||
InfoItem::factory()->create([
|
||||
'item' => $data['item_id'],
|
||||
'sub_item' => $data['sub_item_id'],
|
||||
'needs_image' => 1
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), $data);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'after_image' => __('validation.required', ['attribute' => 'after_image'])
|
||||
'activity_date' => __('validation.date_format', ['attribute' => 'تاریخ فعالیت', 'format' => 'Y-m-d']),
|
||||
'activity_time' => __('validation.date_format', ['attribute' => 'ساعت فعالیت', 'format' => 'H:i']),
|
||||
]);
|
||||
}
|
||||
//
|
||||
// public function test_province_user_is_prohibited_to_access(): void
|
||||
// {
|
||||
// $edarateOstani = EdarateOstani::factory()->create();
|
||||
// $cmmsMachine = CMMSMachine::factory()->create();
|
||||
// $rahdar = Rahdaran::factory()->create();
|
||||
//
|
||||
// $user = User::factory()
|
||||
// ->has(Permission::factory([
|
||||
// 'name' => 'create-road-item'
|
||||
// ]))
|
||||
// ->create([
|
||||
// 'edarate_ostani_id' => $edarateOstani->id
|
||||
// ]);
|
||||
//
|
||||
// $data = [
|
||||
// 'start_point' => '12,12',
|
||||
// 'item_id' => $this->faker->numberBetween(1, 10),
|
||||
// 'sub_item_id' => $this->faker->numberBetween(1, 10),
|
||||
// 'amount' => $this->faker->numberBetween(1, 10),
|
||||
// 'activity_date' => $this->faker->date(),
|
||||
// 'activity_time' => $this->faker->date('H:i'),
|
||||
// 'before_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
// 'after_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
// 'cmms_machine_id' => $cmmsMachine->id,
|
||||
// 'rahdar_id' => $rahdar->id,
|
||||
// ];
|
||||
//
|
||||
// $response = $this->actingAs($user)->postJson(route('v3.road_items.store'), $data);
|
||||
//
|
||||
// $response->assertStatus(400)
|
||||
// ->assertExactJson([
|
||||
// 'message' => 'امکان ثبت فعالیت برای ادارات استانی و ستادی وجود ندارد!'
|
||||
// ]);
|
||||
// }
|
||||
//
|
||||
// public function test_user_should_have_edarate_shahri_id(): void
|
||||
// {
|
||||
// $city = City::factory()->create();
|
||||
// $cmmsMachine = CMMSMachine::factory()->create();
|
||||
// $rahdar = Rahdaran::factory()->create();
|
||||
//
|
||||
// $user = User::factory()
|
||||
// ->has(Permission::factory([
|
||||
// 'name' => 'create-road-item'
|
||||
// ]))
|
||||
// ->create([
|
||||
// 'city_id' => $city->id
|
||||
// ]);
|
||||
//
|
||||
// $data = [
|
||||
// 'start_point' => '12,12',
|
||||
// 'item_id' => $this->faker->numberBetween(1, 10),
|
||||
// 'sub_item_id' => $this->faker->numberBetween(1, 10),
|
||||
// 'amount' => $this->faker->numberBetween(1, 10),
|
||||
// 'activity_date' => $this->faker->date(),
|
||||
// 'activity_time' => $this->faker->date('H:i'),
|
||||
// 'before_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
// 'after_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
// 'cmms_machine_id' => $cmmsMachine->id,
|
||||
// 'rahdar_id' => $rahdar->id,
|
||||
// ];
|
||||
//
|
||||
// $response = $this->actingAs($user)->postJson(route('v3.road_items.store'), $data);
|
||||
//
|
||||
// $response->assertStatus(400)
|
||||
// ->assertExactJson([
|
||||
// 'message' => 'اداره شهری برای شما در سامانه ثبت نشده است!'
|
||||
// ]);
|
||||
// }
|
||||
//
|
||||
// public function test_end_point_required_when_info_item_needs_end_point(): void
|
||||
// {
|
||||
// $city = City::factory()->create();
|
||||
// $edarateShari = EdarateShahri::factory()->create();
|
||||
// $cmmsMachine = CMMSMachine::factory()->create();
|
||||
// $rahdar = Rahdaran::factory()->create();
|
||||
//
|
||||
// $user = User::factory()
|
||||
// ->has(Permission::factory([
|
||||
// 'name' => 'create-road-item'
|
||||
// ]))
|
||||
// ->create([
|
||||
// 'city_id' => $city->id,
|
||||
// 'edarate_shahri_id' => $edarateShari->id
|
||||
// ]);
|
||||
//
|
||||
// $data = [
|
||||
// 'start_point' => '12,12',
|
||||
// 'item_id' => $this->faker->numberBetween(1, 10),
|
||||
// 'sub_item_id' => $this->faker->numberBetween(1, 10),
|
||||
// 'amount' => $this->faker->numberBetween(1, 10),
|
||||
// 'activity_date' => $this->faker->date(),
|
||||
// 'activity_time' => $this->faker->date('H:i'),
|
||||
// 'before_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
// 'after_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
// 'cmms_machine_id' => $cmmsMachine->id,
|
||||
// 'rahdar_id' => $rahdar->id,
|
||||
// ];
|
||||
//
|
||||
// InfoItem::factory()->create([
|
||||
// 'item' => $data['item_id'],
|
||||
// 'sub_item' => $data['sub_item_id'],
|
||||
// 'needs_end_point' => 1
|
||||
// ]);
|
||||
//
|
||||
// $response = $this->actingAs($user)->postJson(route('v3.road_items.store'), $data);
|
||||
//
|
||||
// $response->assertUnprocessable()
|
||||
// ->assertInvalid([
|
||||
// 'end_point' => __('validation.required', ['attribute' => 'end_point'])
|
||||
// ]);
|
||||
// }
|
||||
//
|
||||
// public function test_before_image_required_when_info_item_needs_image(): void
|
||||
// {
|
||||
// $city = City::factory()->create();
|
||||
// $edarateShari = EdarateShahri::factory()->create();
|
||||
// $cmmsMachine = CMMSMachine::factory()->create();
|
||||
// $rahdar = Rahdaran::factory()->create();
|
||||
//
|
||||
// $user = User::factory()
|
||||
// ->has(Permission::factory([
|
||||
// 'name' => 'create-road-item'
|
||||
// ]))
|
||||
// ->create([
|
||||
// 'city_id' => $city->id,
|
||||
// 'edarate_shahri_id' => $edarateShari->id
|
||||
// ]);
|
||||
//
|
||||
// $data = [
|
||||
// 'start_point' => '12,12',
|
||||
// 'item_id' => $this->faker->numberBetween(1, 10),
|
||||
// 'sub_item_id' => $this->faker->numberBetween(1, 10),
|
||||
// 'amount' => $this->faker->numberBetween(1, 10),
|
||||
// 'activity_date' => $this->faker->date(),
|
||||
// 'activity_time' => $this->faker->date('H:i'),
|
||||
// 'cmms_machine_id' => $cmmsMachine->id,
|
||||
// 'rahdar_id' => $rahdar->id,
|
||||
// ];
|
||||
//
|
||||
// InfoItem::factory()->create([
|
||||
// 'item' => $data['item_id'],
|
||||
// 'sub_item' => $data['sub_item_id'],
|
||||
// 'needs_image' => 1
|
||||
// ]);
|
||||
//
|
||||
// $response = $this->actingAs($user)->postJson(route('v3.road_items.store'), $data);
|
||||
//
|
||||
// $response->assertUnprocessable()
|
||||
// ->assertInvalid([
|
||||
// 'before_image' => __('validation.required', ['attribute' => 'before_image'])
|
||||
// ]);
|
||||
// }
|
||||
//
|
||||
// public function test_after_image_required_when_info_item_needs_image(): void
|
||||
// {
|
||||
// $city = City::factory()->create();
|
||||
// $edarateShari = EdarateShahri::factory()->create();
|
||||
// $cmmsMachine = CMMSMachine::factory()->create();
|
||||
// $rahdar = Rahdaran::factory()->create();
|
||||
//
|
||||
// $user = User::factory()
|
||||
// ->has(Permission::factory([
|
||||
// 'name' => 'create-road-item'
|
||||
// ]))
|
||||
// ->create([
|
||||
// 'city_id' => $city->id,
|
||||
// 'edarate_shahri_id' => $edarateShari->id
|
||||
// ]);
|
||||
//
|
||||
// $data = [
|
||||
// 'start_point' => '12,12',
|
||||
// 'item_id' => $this->faker->numberBetween(1, 10),
|
||||
// 'sub_item_id' => $this->faker->numberBetween(1, 10),
|
||||
// 'amount' => $this->faker->numberBetween(1, 10),
|
||||
// 'activity_date' => $this->faker->date(),
|
||||
// 'activity_time' => $this->faker->date('H:i'),
|
||||
// 'cmms_machine_id' => $cmmsMachine->id,
|
||||
// 'rahdar_id' => $rahdar->id,
|
||||
// ];
|
||||
//
|
||||
// InfoItem::factory()->create([
|
||||
// 'item' => $data['item_id'],
|
||||
// 'sub_item' => $data['sub_item_id'],
|
||||
// 'needs_image' => 1
|
||||
// ]);
|
||||
//
|
||||
// $response = $this->actingAs($user)->postJson(route('v3.road_items.store'), $data);
|
||||
//
|
||||
// $response->assertUnprocessable()
|
||||
// ->assertInvalid([
|
||||
// 'after_image' => __('validation.required', ['attribute' => 'after_image'])
|
||||
// ]);
|
||||
// }
|
||||
//
|
||||
// public function test_can_store_a_new_road_item_project(): void
|
||||
// {
|
||||
// $city = City::factory()->create();
|
||||
// $province = Province::factory()->create();
|
||||
// $edarateShari = EdarateShahri::factory()->create();
|
||||
// $cmmsMachine = CMMSMachine::factory()->create();
|
||||
// $rahdar = Rahdaran::factory()->create();
|
||||
//
|
||||
// LogList::factory()->create([
|
||||
// 'log_unique_code' => 1154
|
||||
// ]);
|
||||
// UserActivityLog::factory()->create();
|
||||
//
|
||||
// $user = User::factory()
|
||||
// ->has(Permission::factory([
|
||||
// 'name' => 'create-road-item'
|
||||
// ]))
|
||||
// ->create([
|
||||
// 'city_id' => $city->id,
|
||||
// 'province_id' => $province->id,
|
||||
// 'edarate_shahri_id' => $edarateShari->id
|
||||
// ]);
|
||||
//
|
||||
// Storage::fake('public');
|
||||
//
|
||||
// $this->mock(NominatimService::class, function (MockInterface $mock) {
|
||||
// $mock->shouldReceive('get_way_id_from_nominatim')
|
||||
// ->once()
|
||||
// ->andReturn(0);
|
||||
// });
|
||||
//
|
||||
// $data = [
|
||||
// 'start_point' => '12,12',
|
||||
// 'item_id' => $this->faker->numberBetween(1, 10),
|
||||
// 'sub_item_id' => $this->faker->numberBetween(1, 10),
|
||||
// 'amount' => $this->faker->numberBetween(1, 10),
|
||||
// 'activity_date' => $this->faker->date(),
|
||||
// 'activity_time' => $this->faker->date('H:i'),
|
||||
// 'before_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
// 'after_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
// 'cmms_machine_id' => $cmmsMachine->id,
|
||||
// 'rahdar_id' => $rahdar->id,
|
||||
// ];
|
||||
//
|
||||
// $infoItem = InfoItem::factory()->create([
|
||||
// 'item' => $data['item_id'],
|
||||
// 'sub_item' => $data['sub_item_id'],
|
||||
// 'needs_image' => 1
|
||||
// ]);
|
||||
//
|
||||
// $response = $this->actingAs($user)->postJson(route('v3.road_items.store'), $data);
|
||||
//
|
||||
// $response->assertOk()
|
||||
// ->assertExactJson([
|
||||
// 'message' => __('messages.successful')
|
||||
// ]);
|
||||
//
|
||||
// $this->assertDatabaseHas('road_items_projects', [
|
||||
// 'start_lat' => 12,
|
||||
// 'start_lng' => 12,
|
||||
// 'item' => $data['item_id'],
|
||||
// 'sub_item' => $data['sub_item_id'],
|
||||
// 'province_id' => $province->id,
|
||||
// 'city_id' => $city->id,
|
||||
// 'user_name' => $user->name,
|
||||
// 'start_way_id' => 0,
|
||||
// 'info_id' => $infoItem->id,
|
||||
// 'status' => 0,
|
||||
// 'status_fa' => 'در حال بررسی',
|
||||
// 'edarat_id' => $user->edarate_shahri_id,
|
||||
// 'cmms_machine_id' => $cmmsMachine->id,
|
||||
// 'cmms_machine_code' => $cmmsMachine->machine_code,
|
||||
// 'rahdar_id' => $rahdar->id,
|
||||
// 'rahdar_code' => $rahdar->code
|
||||
// ]);
|
||||
//
|
||||
// $this->assertDatabaseHas('user_activity_logs', [
|
||||
// 'user_id' => $user->id,
|
||||
// 'username' => $user->username,
|
||||
// 'log_unique_code' => 1154,
|
||||
// ]);
|
||||
//
|
||||
|
||||
public function test_can_store_a_new_road_item_project(): void
|
||||
{
|
||||
$city = City::factory()->create();
|
||||
$province = Province::factory()->create();
|
||||
$edarateShari = EdarateShahri::factory()->create();
|
||||
$cmmsMachine = CMMSMachine::factory()->create();
|
||||
$rahdar = Rahdaran::factory()->create();
|
||||
|
||||
LogList::factory()->create([
|
||||
'log_unique_code' => 1154
|
||||
]);
|
||||
UserActivityLog::factory()->create();
|
||||
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create([
|
||||
'city_id' => $city->id,
|
||||
'province_id' => $province->id,
|
||||
'edarate_shahri_id' => $edarateShari->id
|
||||
]);
|
||||
|
||||
Storage::fake('public');
|
||||
|
||||
$this->mock(NominatimService::class, function (MockInterface $mock) {
|
||||
$mock->shouldReceive('get_way_id_from_nominatim')
|
||||
->once()
|
||||
->andReturn(0);
|
||||
});
|
||||
|
||||
$data = [
|
||||
'start_point' => '12,12',
|
||||
'item_id' => $this->faker->numberBetween(1, 10),
|
||||
'sub_item_id' => $this->faker->numberBetween(1, 10),
|
||||
'amount' => $this->faker->numberBetween(1, 10),
|
||||
'activity_date' => $this->faker->date(),
|
||||
'activity_time' => $this->faker->date('H:i'),
|
||||
'before_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
'after_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
'cmms_machine_id' => $cmmsMachine->id,
|
||||
'rahdar_id' => $rahdar->id,
|
||||
];
|
||||
|
||||
$infoItem = InfoItem::factory()->create([
|
||||
'item' => $data['item_id'],
|
||||
'sub_item' => $data['sub_item_id'],
|
||||
'needs_image' => 1
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), $data);
|
||||
|
||||
$response->assertOk()
|
||||
->assertExactJson([
|
||||
'message' => __('messages.successful')
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('road_items_projects', [
|
||||
'start_lat' => 12,
|
||||
'start_lng' => 12,
|
||||
'item' => $data['item_id'],
|
||||
'sub_item' => $data['sub_item_id'],
|
||||
'province_id' => $province->id,
|
||||
'city_id' => $city->id,
|
||||
'user_name' => $user->name,
|
||||
'start_way_id' => 0,
|
||||
'info_id' => $infoItem->id,
|
||||
'status' => 0,
|
||||
'status_fa' => 'در حال بررسی',
|
||||
'edarat_id' => $user->edarate_shahri_id,
|
||||
'cmms_machine_id' => $cmmsMachine->id,
|
||||
'cmms_machine_code' => $cmmsMachine->machine_code,
|
||||
'rahdar_id' => $rahdar->id,
|
||||
'rahdar_code' => $rahdar->code
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('user_activity_logs', [
|
||||
'user_id' => $user->id,
|
||||
'username' => $user->username,
|
||||
'log_unique_code' => 1154,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,13 @@ class SupervisorIndexTest extends TestCase
|
||||
|
||||
$response->assertForbidden();
|
||||
}
|
||||
public function test_user_cannot_access_authentication_to_supervisor_index(): void
|
||||
{
|
||||
$response = $this->getJson(route('v3.road_items.supervisorIndex'));
|
||||
|
||||
$response->assertStatus(401);
|
||||
}
|
||||
|
||||
|
||||
public function test_supervisor_can_see_the_data_table(): void
|
||||
{
|
||||
@@ -47,49 +54,21 @@ class SupervisorIndexTest extends TestCase
|
||||
'data' => [
|
||||
'*' => [
|
||||
"id",
|
||||
"user_id",
|
||||
"start_lat",
|
||||
"start_lng",
|
||||
"end_lat",
|
||||
"end_lng",
|
||||
"project_distance",
|
||||
"item",
|
||||
"item_fa",
|
||||
"sub_item",
|
||||
"sub_item_fa",
|
||||
"sub_item_data",
|
||||
"sub_items",
|
||||
"sub_items_data",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
"province_id",
|
||||
"province_fa",
|
||||
"city_id",
|
||||
"city_fa",
|
||||
"is_new",
|
||||
"parent_id",
|
||||
"start_way_id",
|
||||
"end_way_id",
|
||||
"unit_fa",
|
||||
"user_name",
|
||||
"created_at_fa",
|
||||
"info_id",
|
||||
"status",
|
||||
"status_fa",
|
||||
"edarat_id",
|
||||
"edarat_name",
|
||||
"edarat_type",
|
||||
"activity_date",
|
||||
"activity_time",
|
||||
"activity_date_time",
|
||||
"supervisor_id",
|
||||
"supervisor_name",
|
||||
"supervisor_description",
|
||||
"supervising_time",
|
||||
"cmms_machine_id",
|
||||
"cmms_machine_code",
|
||||
"rahdar_id",
|
||||
"rahdar_code",
|
||||
"can_supervise",
|
||||
],
|
||||
]
|
||||
|
||||
133
tests/Feature/V3/RoadItemsProject/VerifyBySupervisor.php
Normal file
133
tests/Feature/V3/RoadItemsProject/VerifyBySupervisor.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\V3\RoadItemsProject;
|
||||
|
||||
use App\Models\Permission;
|
||||
use App\Models\RoadItemsProject;
|
||||
use App\Models\UserActivityLog;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Mockery;
|
||||
use App\Models\LogList;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
|
||||
|
||||
class VerifyBySupervisor extends TestCase
|
||||
{
|
||||
use RefreshDatabase, WithFaker;
|
||||
|
||||
public function test_user_cannot_access_authentication_to_verify_by_supervisor(): void
|
||||
{
|
||||
$roadItem = RoadItemsProject::factory()->create();
|
||||
|
||||
$response = $this->postJson(route('v3.road_items.VerifyBySupervisor', [$roadItem->id]));
|
||||
|
||||
$response->assertStatus(401);
|
||||
}
|
||||
|
||||
public function test_supervisor_without_permission_cannot_verify_road_item(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
Gate::shouldReceive('allows')
|
||||
->andReturn(false);
|
||||
|
||||
$roadItem = RoadItemsProject::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.VerifyBySupervisor', [$roadItem->id,]));
|
||||
|
||||
$response->assertForbidden();
|
||||
}
|
||||
public function test_validation_fails_when_required_fields_are_missing(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$roadItem = RoadItemsProject::factory()->create();
|
||||
|
||||
Gate::shouldReceive('allows')
|
||||
->andReturn(true);
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.VerifyBySupervisor', [$roadItem->id]));
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'verify' => __('validation.required', ['attribute' => 'verify']),
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_validation_fails_when_verify_field_is_invalid(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$roadItem = RoadItemsProject::factory()->create();
|
||||
|
||||
Gate::shouldReceive('allows')
|
||||
->andReturn(true);
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.VerifyBySupervisor', [$roadItem->id]), [
|
||||
'verify' => 5,
|
||||
'description' => $this->faker()->sentence(),
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'verify' => __('validation.in', ['attribute' => 'verify']),
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_verify_description_must_be_string(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$roadItem = RoadItemsProject::factory()->create();
|
||||
|
||||
Gate::shouldReceive('allows')
|
||||
->andReturn(true);
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.VerifyBySupervisor', [$roadItem->id]), [
|
||||
'description' => 12345,
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'description' => __('validation.string', ['attribute' =>"توضیحات"]),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function test_supervisor_can_view_road_item_data(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
LogList::factory()->create([
|
||||
'log_unique_code' => 1149,
|
||||
]);
|
||||
UserActivityLog::factory()->create();
|
||||
|
||||
$roadItem = RoadItemsProject::factory()->create();
|
||||
|
||||
Gate::shouldReceive('allows')
|
||||
->andReturn(true);
|
||||
|
||||
$description = fake()->sentence();
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.VerifyBySupervisor', [$roadItem->id,]), [
|
||||
'verify' => 1,
|
||||
'description' =>$description,
|
||||
]);
|
||||
|
||||
$response->assertOk()
|
||||
->assertJson([
|
||||
'message' => __('messages.successful'),
|
||||
]);
|
||||
$this->assertDatabaseHas('road_items_projects', [
|
||||
'id' => $roadItem->id,
|
||||
'status' => 1,
|
||||
'status_fa' => 'تایید شده',
|
||||
'supervisor_id' => $user->id,
|
||||
'supervisor_name' => $user->name,
|
||||
'supervisor_description' =>$description,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user