change the notification service
This commit is contained in:
@@ -148,7 +148,9 @@ class NotificationController extends Controller
|
|||||||
['status', '=', 0]
|
['status', '=', 0]
|
||||||
])->count();
|
])->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')) {
|
elseif ($user->hasPermissionTo('show-fast-react-province')) {
|
||||||
throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!'));
|
throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!'));
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Services\Cartables\RoadObservation;
|
namespace App\Services\Cartables\RoadObservation;
|
||||||
|
|
||||||
|
use App\Exceptions\ProhibitedAction;
|
||||||
use App\Facades\DataTable\DataTableFacade;
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
use App\Models\RoadObserved;
|
use App\Models\RoadObserved;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -35,6 +36,9 @@ class OperatorService
|
|||||||
allowedSortings: ['*']);
|
allowedSortings: ['*']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Throwable
|
||||||
|
*/
|
||||||
public function complaintsIndex(Request $request)
|
public function complaintsIndex(Request $request)
|
||||||
{
|
{
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
@@ -46,33 +50,26 @@ class OperatorService
|
|||||||
if ($user->hasPermissionTo('show-fast-react')) {
|
if ($user->hasPermissionTo('show-fast-react')) {
|
||||||
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
||||||
->where('rms_status', '=', 0)
|
->where('rms_status', '=', 0)
|
||||||
->whereNotNull('edarate_shahri_id')
|
->whereNotNull('edarate_shahri_id');
|
||||||
->selectRaw($fields);
|
|
||||||
}
|
}
|
||||||
elseif ($user->hasPermissionTo('show-fast-react-province')) {
|
elseif ($user->hasPermissionTo('show-fast-react-province')) {
|
||||||
|
|
||||||
if (is_null($user->province_id)) {
|
throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!'));
|
||||||
return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!');
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
||||||
->where('rms_status', '=', 0)
|
->where('rms_status', '=', 0)
|
||||||
->whereNotNull('road_observeds.province_id')
|
->whereNotNull('road_observeds.province_id')
|
||||||
->where('road_observeds.province_id', '=', $user->province_id)
|
->where('road_observeds.province_id', '=', $user->province_id);
|
||||||
->selectRaw($fields);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif ($user->hasPermissionTo('show-fast-react-edarate-shahri')) {
|
elseif ($user->hasPermissionTo('show-fast-react-edarate-shahri')) {
|
||||||
|
|
||||||
if (is_null($user->edarate_shahri_id)) {
|
throw_if(is_null($user->edarate_shahri_id), new ProhibitedAction('اداره ای برای شما در سامانه ثبت نشده است!'));
|
||||||
return $this->errorResponse('اداره ای برای شما در سامانه ثبت نشده است!');
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
||||||
->where('rms_status', '=', 0)
|
->where('rms_status', '=', 0)
|
||||||
->whereNotNull('edarate_shahri_id')
|
->whereNotNull('edarate_shahri_id')
|
||||||
->where('edarate_shahri_id', '=', $user->edarate_shahri_id)
|
->where('edarate_shahri_id', '=', $user->edarate_shahri_id);
|
||||||
->selectRaw($fields);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,50 +77,8 @@ class OperatorService
|
|||||||
$query,
|
$query,
|
||||||
$request,
|
$request,
|
||||||
allowedFilters: ['*'],
|
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,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,12 +2,16 @@
|
|||||||
|
|
||||||
namespace App\Services\Cartables\RoadObservation;
|
namespace App\Services\Cartables\RoadObservation;
|
||||||
|
|
||||||
|
use App\Exceptions\ProhibitedAction;
|
||||||
use App\Facades\DataTable\DataTableFacade;
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
use App\Models\RoadObserved;
|
use App\Models\RoadObserved;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class SupervisorService
|
class SupervisorService
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @throws \Throwable
|
||||||
|
*/
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
@@ -27,10 +31,7 @@ class SupervisorService
|
|||||||
}
|
}
|
||||||
elseif ($user->hasPermissionTo('show-fast-react-province'))
|
elseif ($user->hasPermissionTo('show-fast-react-province'))
|
||||||
{
|
{
|
||||||
if (is_null($user->province_id))
|
throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!'));
|
||||||
{
|
|
||||||
return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!');
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
||||||
->where('road_observeds.province_id', $user->province_id)
|
->where('road_observeds.province_id', $user->province_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user