create mission tables with factory and seeder
This commit is contained in:
@@ -129,8 +129,8 @@ class RoadObservationProblems extends Command
|
||||
'rms_city_id' => NikarayanComplaints::mapCities((int) $value->fk_Town) ?? null,
|
||||
'observed_way_id' => $nominatimService->get_way_id_from_nominatim($value->XGeo, $value->YGeo) ?? null,
|
||||
|
||||
'province_id' => $city ? $city['province_id'] : null,
|
||||
'city_id' => $city ? $city['city_id'] : null,
|
||||
'province_id' => $cityModel->province()->first()->id,
|
||||
'city_id' => $cityModel->id,
|
||||
// 'handler_type' => EdarateShahri::class,
|
||||
'edarate_shahri_id' => $cityModel->edarateShahri()->first()->id,
|
||||
'province_fa' => (isset($city['province_id']) ? Province::find($city['province_id'])->name_fa : null),
|
||||
@@ -147,7 +147,7 @@ class RoadObservationProblems extends Command
|
||||
return $result;
|
||||
}
|
||||
echo 'done at: ' . date("Y-m-d H:i:s") . "\n";
|
||||
$this->info("{$affectedRows} row's affected");
|
||||
echo "{$affectedRows} row's affected";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,10 @@ class Kernel extends ConsoleKernel
|
||||
->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'));
|
||||
->dailyAt('00:17')->appendOutputTo(storage_path('logs/nikarayan.log'));
|
||||
|
||||
$schedule->command("webservice:roadobserved --daily-mode")
|
||||
->dailyAt('00:47')->appendOutputTo(storage_path('logs/nikarayan.log'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\Mission;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CartableController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\Reports;
|
||||
|
||||
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 SafetyAndPrivacyReportController 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);
|
||||
}
|
||||
}
|
||||
@@ -21,36 +21,4 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,269 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard;
|
||||
|
||||
use App\Enums\AxisTypes;
|
||||
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;
|
||||
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 SafetyAndPrivacyController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function operatorIndex(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse
|
||||
{
|
||||
return response()->json($safetyAndPrivacyTableService->operatorDatatable($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function operatorExcelReport(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,
|
||||
]);
|
||||
|
||||
$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 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);
|
||||
}
|
||||
}
|
||||
29
app/Models/Mission.php
Normal file
29
app/Models/Mission.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
||||
|
||||
class Mission extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function roadItems(): MorphToMany
|
||||
{
|
||||
return $this->morphedByMany(RoadItemsProject::class, 'missionable');
|
||||
}
|
||||
|
||||
public function roadPatrols(): MorphToMany
|
||||
{
|
||||
return $this->morphedByMany(RoadPatrol::class, 'missionable');
|
||||
}
|
||||
|
||||
public function roadObserveds(): MorphToMany
|
||||
{
|
||||
return $this->morphedByMany(RoadObserved::class, 'missionable');
|
||||
}
|
||||
}
|
||||
13
app/Models/MissionHistory.php
Normal file
13
app/Models/MissionHistory.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MissionHistory extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
}
|
||||
11
app/Models/MissionState.php
Normal file
11
app/Models/MissionState.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MissionState extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
@@ -187,4 +187,14 @@ class RoadItemsProject extends Model
|
||||
'rahdar_id',
|
||||
);
|
||||
}
|
||||
|
||||
public function missions(): MorphToMany
|
||||
{
|
||||
return $this->morphToMany(Mission::class,
|
||||
'missionable',
|
||||
'missionables',
|
||||
'missionable_id',
|
||||
'mission_id',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class RoadObserved extends Model
|
||||
@@ -124,4 +125,14 @@ class RoadObserved extends Model
|
||||
: Storage::disk('public')->url($value))
|
||||
);
|
||||
}
|
||||
|
||||
public function missions(): MorphToMany
|
||||
{
|
||||
return $this->morphToMany(Mission::class,
|
||||
'missionable',
|
||||
'missionables',
|
||||
'missionable_id',
|
||||
'mission_id',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,4 +45,14 @@ class RoadPatrol extends Model
|
||||
'rahdar_id',
|
||||
);
|
||||
}
|
||||
|
||||
public function missions(): MorphToMany
|
||||
{
|
||||
return $this->morphToMany(Mission::class,
|
||||
'missionable',
|
||||
'missionables',
|
||||
'missionable_id',
|
||||
'mission_id',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
23
database/factories/MissionFactory.php
Normal file
23
database/factories/MissionFactory.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Mission>
|
||||
*/
|
||||
class MissionFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
23
database/factories/MissionHistoryFactory.php
Normal file
23
database/factories/MissionHistoryFactory.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\MissionHistory>
|
||||
*/
|
||||
class MissionHistoryFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
23
database/factories/MissionStateFactory.php
Normal file
23
database/factories/MissionStateFactory.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\MissionState>
|
||||
*/
|
||||
class MissionStateFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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::create('mission_states', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('mission_states');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
<?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::create('missions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained('users');
|
||||
$table->foreignId('machine_id')->nullable()->constrained('cmms_machines');
|
||||
$table->foreignId('rahdar_id')->constrained('rahdaran');
|
||||
$table->foreignId('state_id')->constrained('mission_states');
|
||||
$table->string('state_name');
|
||||
$table->string('requested_machine_type');
|
||||
$table->string('requested_machine_numbers');
|
||||
$table->string('type');
|
||||
$table->dateTime('start_date');
|
||||
$table->dateTime('end_date');
|
||||
$table->dateTime('request_date');
|
||||
$table->text('description')->nullable();
|
||||
$table->string('start_point');
|
||||
$table->string('end_point');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('missions');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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::create('missionables', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('mission_id')->constrained('missions')->noActionOnDelete();
|
||||
$table->morphs('missionable');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('missionables');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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::create('mission_histories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('mission_id')->constrained('missions');
|
||||
$table->foreignId('user_id')->constrained('users');
|
||||
$table->foreignId('previous_state_id')->constrained('mission_states');
|
||||
$table->string('previous_state_name');
|
||||
$table->text('user_description')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('mission_histories');
|
||||
}
|
||||
};
|
||||
17
database/seeders/MissionHistorySeeder.php
Normal file
17
database/seeders/MissionHistorySeeder.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class MissionHistorySeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
18
database/seeders/MissionSeeder.php
Normal file
18
database/seeders/MissionSeeder.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Mission;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class MissionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
Mission::factory()->count(5)->create();
|
||||
}
|
||||
}
|
||||
17
database/seeders/MissionStateSeeder.php
Normal file
17
database/seeders/MissionStateSeeder.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class MissionStateSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@ 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;
|
||||
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;
|
||||
@@ -383,13 +382,6 @@ Route::prefix('safety_and_privacy_report')
|
||||
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')
|
||||
|
||||
Reference in New Issue
Block a user