create history api
This commit is contained in:
@@ -24,8 +24,10 @@ class DetailController extends Controller
|
||||
*/
|
||||
public function histories(Harim $harim): JsonResponse
|
||||
{
|
||||
throw_if($this->harim->edareh_shahri_id == auth()->user()->edarate_shahri_id, new ProhibitedAction("unauthorized"));
|
||||
throw_if($harim->province_id != auth()->user()->province_id, new ProhibitedAction("شما دسترسی لازم جهت مشاهده ی این صفحه را ندارید"));
|
||||
|
||||
return $this->successResponse($harim->histories()->get(['id', 'expert_description', 'action_name', 'previous_state_name']));
|
||||
return $this->successResponse($harim->histories()
|
||||
->orderBy('id', 'desc')
|
||||
->get(['id', 'expert_description', 'action_name', 'previous_state_name']));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,15 @@ class GeneralManagerController extends Controller
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = Harim::query()
|
||||
->where('province_id', '=', auth()->user()->province_id);
|
||||
->where('province_id', '=', auth()->user()->province_id)
|
||||
->orderByRaw("
|
||||
CASE state
|
||||
WHEN 4 THEN 1
|
||||
WHEN 7 THEN 2
|
||||
WHEN 15 THEN 3
|
||||
ELSE 4
|
||||
END
|
||||
");
|
||||
|
||||
$data = DataTableFacade::run(
|
||||
$query,
|
||||
@@ -178,7 +186,7 @@ class GeneralManagerController extends Controller
|
||||
|
||||
public function show(ShowRequest $request, Harim $harim): JsonResponse
|
||||
{
|
||||
return $this->successResponse($harim->load('histories'));
|
||||
return $this->successResponse($harim);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,7 +28,15 @@ class HarimOfficeController extends Controller
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = Harim::query()
|
||||
->where('province_id', '=', auth()->user()->province_id);
|
||||
->where('province_id', '=', auth()->user()->province_id)
|
||||
->orderByRaw("
|
||||
CASE state
|
||||
WHEN 2 THEN 1
|
||||
WHEN 5 THEN 2
|
||||
WHEN 13 THEN 3
|
||||
ELSE 4
|
||||
END
|
||||
");
|
||||
|
||||
$data = DataTableFacade::run(
|
||||
$query,
|
||||
|
||||
@@ -22,7 +22,13 @@ class ProvinceOfficeController extends Controller
|
||||
{
|
||||
$user = auth()->user();
|
||||
$query = Harim::query()
|
||||
->where('edareh_shahri_id', '=', $user->edarate_shahri_id);
|
||||
->where('edareh_shahri_id', '=', $user->edarate_shahri_id)
|
||||
->orderByRaw("
|
||||
CASE state
|
||||
WHEN 1 THEN 1
|
||||
ELSE 2
|
||||
END
|
||||
");
|
||||
|
||||
$data = DataTableFacade::run(
|
||||
$query,
|
||||
|
||||
@@ -26,7 +26,15 @@ class TechnicalDeputyController extends Controller
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = Harim::query()
|
||||
->where('province_id', '=', auth()->user()->province_id);
|
||||
->where('province_id', '=', auth()->user()->province_id)
|
||||
->orderByRaw("
|
||||
CASE state
|
||||
WHEN 3 THEN 1
|
||||
WHEN 6 THEN 2
|
||||
WHEN 14 THEN 3
|
||||
ELSE 4
|
||||
END
|
||||
");
|
||||
|
||||
$data = DataTableFacade::run(
|
||||
$query,
|
||||
|
||||
@@ -112,10 +112,10 @@ class RoadMaintenanceStationController extends Controller
|
||||
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_province_id' => $rahdariPoint->province_id,
|
||||
'previous_province_name' => $rahdariPoint->province_name,
|
||||
'previous_city_id' => $rahdariPoint->city_id,
|
||||
'previous_city_name' => $rahdariPoint->city_name,
|
||||
'previous_name' => $rahdariPoint->name,
|
||||
'previous_status' => $rahdariPoint->status,
|
||||
'previous_type' => $rahdariPoint->type,
|
||||
|
||||
@@ -537,6 +537,7 @@ Route::prefix('harim')
|
||||
->controller(\App\Http\Controllers\V3\Dashboard\Harim\DetailController::class)
|
||||
->group(function () {
|
||||
Route::get('/states', 'states')->name('states');
|
||||
Route::get('/histories/{harim}', 'histories')->name('histories');
|
||||
});
|
||||
|
||||
Route::prefix('province_office')
|
||||
|
||||
Reference in New Issue
Block a user