change the notification service

This commit is contained in:
2025-05-31 11:36:18 +03:30
parent 6521ad691d
commit e85a99d50e
3 changed files with 19 additions and 61 deletions

View File

@@ -148,7 +148,9 @@ class NotificationController extends Controller
['status', '=', 0]
])->count();
$road_observations['complaint_cnt'] = RoadObserved::query()->where('rms_status', '=', 0)->count();
$road_observations['complaint_cnt'] = RoadObserved::query()->where('rms_status', '=', 0)
->whereNotNull('edarate_shahri_id')
->count();
}
elseif ($user->hasPermissionTo('show-fast-react-province')) {
throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!'));

View File

@@ -2,6 +2,7 @@
namespace App\Services\Cartables\RoadObservation;
use App\Exceptions\ProhibitedAction;
use App\Facades\DataTable\DataTableFacade;
use App\Models\RoadObserved;
use Illuminate\Http\Request;
@@ -35,6 +36,9 @@ class OperatorService
allowedSortings: ['*']);
}
/**
* @throws \Throwable
*/
public function complaintsIndex(Request $request)
{
$user = auth()->user();
@@ -46,33 +50,26 @@ class OperatorService
if ($user->hasPermissionTo('show-fast-react')) {
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
->where('rms_status', '=', 0)
->whereNotNull('edarate_shahri_id')
->selectRaw($fields);
->whereNotNull('edarate_shahri_id');
}
elseif ($user->hasPermissionTo('show-fast-react-province')) {
if (is_null($user->province_id)) {
return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!');
}
throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!'));
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
->where('rms_status', '=', 0)
->whereNotNull('road_observeds.province_id')
->where('road_observeds.province_id', '=', $user->province_id)
->selectRaw($fields);
->where('road_observeds.province_id', '=', $user->province_id);
}
elseif ($user->hasPermissionTo('show-fast-react-edarate-shahri')) {
if (is_null($user->edarate_shahri_id)) {
return $this->errorResponse('اداره ای برای شما در سامانه ثبت نشده است!');
}
throw_if(is_null($user->edarate_shahri_id), new ProhibitedAction('اداره ای برای شما در سامانه ثبت نشده است!'));
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
->where('rms_status', '=', 0)
->whereNotNull('edarate_shahri_id')
->where('edarate_shahri_id', '=', $user->edarate_shahri_id)
->selectRaw($fields);
->where('edarate_shahri_id', '=', $user->edarate_shahri_id);
}
@@ -80,50 +77,8 @@ class OperatorService
$query,
$request,
allowedFilters: ['*'],
allowedSortings: ['*']
allowedSortings: ['*'],
allowedSelects: $fields
);
}
public function reportIndex(Request $request)
{
$fromDate = $request->from_date . ' 00:00:00';
$toDate = $request->date_to . ' 23:59:59';
$fields = [
'fk_RegisteredEventMessage',
'road_observeds.id',
'Title',
'road_observeds.created_at',
'lat',
'lng',
'FeatureTypeTitle',
'Description',
'MobileForSendEventSms',
'road_observeds.province_id',
'province_fa',
'city_fa',
'edarate_shahri.name_fa',
'rms_last_activity_fa',
'rms_description'
];
$query = RoadObserved::leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
->where('rms_status', "<>", 0)
->whereNotNull('edarate_shahri_id')
->whereBetween('road_observeds.created_at', [$fromDate, $toDate])
->select($fields);
$data = DataTableFacade::run(
$query,
$request,
allowedFilters: ['*'],
allowedSortings: ['*']
);
return [
'data' => $data,
'fromDate' => $fromDate,
'toDate' => $toDate,
];
}
}

View File

@@ -2,12 +2,16 @@
namespace App\Services\Cartables\RoadObservation;
use App\Exceptions\ProhibitedAction;
use App\Facades\DataTable\DataTableFacade;
use App\Models\RoadObserved;
use Illuminate\Http\Request;
class SupervisorService
{
/**
* @throws \Throwable
*/
public function index(Request $request)
{
$user = auth()->user();
@@ -27,10 +31,7 @@ class SupervisorService
}
elseif ($user->hasPermissionTo('show-fast-react-province'))
{
if (is_null($user->province_id))
{
return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!');
}
throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!'));
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
->where('road_observeds.province_id', $user->province_id)