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