use builder for query
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\HeadquartersDashboard;
|
|||||||
|
|
||||||
use App\Facades\DataTable\DataTableFacade;
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\CountryCallsReport;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
@@ -12,8 +13,8 @@ class CumulativeCentersStatsController extends Controller
|
|||||||
{
|
{
|
||||||
public function index(Request $request): JsonResponse
|
public function index(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$query = DB::table('country_calls_reports')->selectRaw("
|
$query = DB::table('country_calls_reports')
|
||||||
SELECT
|
->selectRaw("
|
||||||
province_id,
|
province_id,
|
||||||
province_name,
|
province_name,
|
||||||
SUM(total) as total,
|
SUM(total) as total,
|
||||||
@@ -29,27 +30,28 @@ class CumulativeCentersStatsController extends Controller
|
|||||||
SUM(talked_to_operator) as talked_to_operator,
|
SUM(talked_to_operator) as talked_to_operator,
|
||||||
AVG(average_calls_time) as average_calls_time,
|
AVG(average_calls_time) as average_calls_time,
|
||||||
SUM(fails) as fails
|
SUM(fails) as fails
|
||||||
GROUP BY province_id, province_name
|
")
|
||||||
|
->groupBy('province_id', 'province_name')
|
||||||
UNION ALL
|
->unionAll(
|
||||||
|
DB::table('country_calls_reports')
|
||||||
SELECT
|
->selectRaw("
|
||||||
0 as province_id,
|
0 as province_id,
|
||||||
'کشور' as province_name,
|
'کشوری' as province_name,
|
||||||
SUM(total),
|
SUM(total),
|
||||||
SUM(route_to_teh4),
|
SUM(route_to_teh4),
|
||||||
SUM(route_to_teh5),
|
SUM(route_to_teh5),
|
||||||
SUM(route_to_os4),
|
SUM(route_to_os4),
|
||||||
SUM(route_to_os5),
|
SUM(route_to_os5),
|
||||||
SUM(answered),
|
SUM(answered),
|
||||||
SUM(answered_over10),
|
SUM(answered_over10),
|
||||||
SUM(missed),
|
SUM(missed),
|
||||||
SUM(dnd),
|
SUM(dnd),
|
||||||
SUM(transferred),
|
SUM(transferred),
|
||||||
SUM(talked_to_operator),
|
SUM(talked_to_operator),
|
||||||
AVG(average_calls_time),
|
AVG(average_calls_time),
|
||||||
SUM(fails)
|
SUM(fails)
|
||||||
");
|
")
|
||||||
|
);
|
||||||
|
|
||||||
return response()->json(
|
return response()->json(
|
||||||
DataTableFacade::run(
|
DataTableFacade::run(
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ class CumulativeKeypressStatsController extends Controller
|
|||||||
public function index(Request $request): JsonResponse
|
public function index(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$query = DB::table('country_keypress_reports')->selectRaw("
|
$query = DB::table('country_keypress_reports')->selectRaw("
|
||||||
SELECT
|
|
||||||
province_id,
|
province_id,
|
||||||
province_name,
|
province_name,
|
||||||
SUM(total) as total,
|
SUM(total) as total,
|
||||||
@@ -31,29 +30,27 @@ class CumulativeKeypressStatsController extends Controller
|
|||||||
SUM(key2_1) as key2_1,
|
SUM(key2_1) as key2_1,
|
||||||
SUM(key2_2) as key2_2,
|
SUM(key2_2) as key2_2,
|
||||||
SUM(key2_3) as key2_3
|
SUM(key2_3) as key2_3
|
||||||
GROUP BY province_id, province_name
|
")
|
||||||
|
->groupBy('province_id', 'province_name')
|
||||||
UNION ALL
|
->unionAll(DB::table('country_keypress_reports')->selectRaw("
|
||||||
|
0 as province_id,
|
||||||
SELECT
|
'کشوری' as province_name,
|
||||||
0 as province_id,
|
SUM(total),
|
||||||
'کشوری' as province_name,
|
SUM(key1),
|
||||||
SUM(total),
|
SUM(key2),
|
||||||
SUM(key1),
|
SUM(key3),
|
||||||
SUM(key2),
|
SUM(key4),
|
||||||
SUM(key3),
|
SUM(key5),
|
||||||
SUM(key4),
|
SUM(key6),
|
||||||
SUM(key5),
|
SUM(key9),
|
||||||
SUM(key6),
|
SUM(key4_1),
|
||||||
SUM(key9),
|
SUM(key4_2),
|
||||||
SUM(key4_1),
|
SUM(key5_1),
|
||||||
SUM(key4_2),
|
SUM(key5_2),
|
||||||
SUM(key5_1),
|
SUM(key2_1),
|
||||||
SUM(key5_2),
|
SUM(key2_2),
|
||||||
SUM(key2_1),
|
SUM(key2_3)
|
||||||
SUM(key2_2),
|
"));
|
||||||
SUM(key2_3)
|
|
||||||
");
|
|
||||||
|
|
||||||
return response()->json(
|
return response()->json(
|
||||||
DataTableFacade::run(
|
DataTableFacade::run(
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ class CumulativeMessageRatingStatsController extends Controller
|
|||||||
public function index(Request $request): JsonResponse
|
public function index(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$query = DB::table('country_message_rating_reports')->selectRaw("
|
$query = DB::table('country_message_rating_reports')->selectRaw("
|
||||||
SELECT
|
|
||||||
province_id,
|
province_id,
|
||||||
province_name,
|
province_name,
|
||||||
SUM(total) as total,
|
SUM(total) as total,
|
||||||
@@ -26,11 +25,9 @@ class CumulativeMessageRatingStatsController extends Controller
|
|||||||
SUM(action3) as action3,
|
SUM(action3) as action3,
|
||||||
SUM(action4) as action4,
|
SUM(action4) as action4,
|
||||||
SUM(action5) as action5
|
SUM(action5) as action5
|
||||||
GROUP BY province_id, province_name
|
")
|
||||||
|
->groupBy('province_id', 'province_name')
|
||||||
UNION ALL
|
->unionAll(DB::table('country_message_rating_reports')->selectRaw("
|
||||||
|
|
||||||
SELECT
|
|
||||||
0 as province_id,
|
0 as province_id,
|
||||||
'کشوری' as province_name,
|
'کشوری' as province_name,
|
||||||
SUM(total),
|
SUM(total),
|
||||||
@@ -42,7 +39,7 @@ class CumulativeMessageRatingStatsController extends Controller
|
|||||||
SUM(action3),
|
SUM(action3),
|
||||||
SUM(action4),
|
SUM(action4),
|
||||||
SUM(action5)
|
SUM(action5)
|
||||||
");
|
"));
|
||||||
|
|
||||||
return response()->json(
|
return response()->json(
|
||||||
DataTableFacade::run(
|
DataTableFacade::run(
|
||||||
|
|||||||
@@ -13,25 +13,22 @@ class CumulativeVoiceRatingStatsController extends Controller
|
|||||||
public function index(Request $request): JsonResponse
|
public function index(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$query = DB::table('country_voice_rating_reports')->selectRaw("
|
$query = DB::table('country_voice_rating_reports')->selectRaw("
|
||||||
SELECT
|
|
||||||
province_id,
|
province_id,
|
||||||
province_name,
|
province_name,
|
||||||
SUM(message_quality_ok) as message_quality_ok,
|
SUM(message_quality_ok) as message_quality_ok,
|
||||||
SUM(message_format_ok) as message_format_ok,
|
SUM(message_format_ok) as message_format_ok,
|
||||||
SUM(message_quality_nok) as message_quality_nok,
|
SUM(message_quality_nok) as message_quality_nok,
|
||||||
SUM(message_format_nok) as message_format_nok
|
SUM(message_format_nok) as message_format_nok
|
||||||
GROUP BY province_id, province_name
|
")
|
||||||
|
->groupBy('province_id', 'province_name')
|
||||||
UNION ALL
|
->unionAll(DB::table('country_voice_rating_reports')->selectRaw("
|
||||||
|
|
||||||
SELECT
|
|
||||||
0 as province_id,
|
0 as province_id,
|
||||||
'کشوری' as province_name,
|
'کشوری' as province_name,
|
||||||
SUM(message_quality_ok),
|
SUM(message_quality_ok),
|
||||||
SUM(message_format_ok),
|
SUM(message_format_ok),
|
||||||
SUM(message_quality_nok),
|
SUM(message_quality_nok),
|
||||||
SUM(message_format_nok)
|
SUM(message_format_nok)
|
||||||
");
|
"));
|
||||||
|
|
||||||
return response()->json(
|
return response()->json(
|
||||||
DataTableFacade::run(
|
DataTableFacade::run(
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class StoreRequest extends FormRequest
|
|||||||
'full_name' => 'required|max:255|string',
|
'full_name' => 'required|max:255|string',
|
||||||
'username' => 'required|unique:users,username|string',
|
'username' => 'required|unique:users,username|string',
|
||||||
'position' => 'required',
|
'position' => 'required',
|
||||||
'gender' => 'required|in:1,2',
|
'gender' => 'required|in:male,female',
|
||||||
'national_id' => 'required|digits:10|unique:users,national_id',
|
'national_id' => 'required|digits:10|unique:users,national_id',
|
||||||
'phone_number' => 'required|numeric|digits:11|unique:users,phone_number|regex:/^09\d{9}$/',
|
'phone_number' => 'required|numeric|digits:11|unique:users,phone_number|regex:/^09\d{9}$/',
|
||||||
'province_id' => 'required|exists:provinces,id',
|
'province_id' => 'required|exists:provinces,id',
|
||||||
|
|||||||
Reference in New Issue
Block a user