create and change code
This commit is contained in:
@@ -5,12 +5,12 @@ namespace App\Http\Controllers\V3\Dashboard\Harim;
|
||||
use App\Enums\HarimStates;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\PanjareVahed\GetAccessRoadRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\PanjareVahed\GetRejectRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\PanjareVahed\ReceiveNewRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\City;
|
||||
use App\Models\Harim;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PanjareVahedController extends Controller
|
||||
{
|
||||
@@ -79,4 +79,18 @@ class PanjareVahedController extends Controller
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function getRejectRequest(GetRejectRequest $request)
|
||||
{
|
||||
$state = HarimStates::MOKHALEFAT_BA_DASTGAH->value;
|
||||
|
||||
Harim::query()
|
||||
->firstWhere('panjare_vahed_id', '=', $request->panjare_vahed_id)
|
||||
->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,50 +26,17 @@ class RoadMaintenanceStationController extends Controller
|
||||
$user = auth()->user();
|
||||
$user->addActivityComplete(1019);
|
||||
|
||||
$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));
|
||||
->when($user->hasPermissionTo('show-tollhouse-province') && !$user->hasPermissionTo('show-tollhouse'),
|
||||
fn ($query) => $query->where('province_id', $user->province_id)
|
||||
);
|
||||
|
||||
if ($user->hasPermissionTo('show-tollhouse-province') && !$user->hasPermissionTo('show-tollhouse')) {
|
||||
$query->where('province_id', $user->province_id);
|
||||
}
|
||||
|
||||
$data = DataTableFacade::run(
|
||||
return response()->json(DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
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);
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user