create setad report tables
This commit is contained in:
@@ -4,20 +4,63 @@ namespace App\Http\Controllers\Setad;
|
||||
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Http\Controllers\Controller;
|
||||
use app\Http\Traits\ApiResponse;
|
||||
use App\Models\CountryKeypressReport;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CumulativeKeypressStatsController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$data = DataTableFacade::run(
|
||||
CountryKeypressReport::query(),
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
);
|
||||
return response()->json($data);
|
||||
$data = DB::select("
|
||||
SELECT
|
||||
province_id,
|
||||
province_name,
|
||||
SUM(total) as total,
|
||||
SUM(key1) as key1,
|
||||
SUM(key2) as key2,
|
||||
SUM(key3) as key3,
|
||||
SUM(key4) as key4,
|
||||
SUM(key5) as key5,
|
||||
SUM(key6) as key6,
|
||||
SUM(key9) as key9,
|
||||
SUM(key4_1) as key4_1,
|
||||
SUM(key4_2) as key4_2,
|
||||
SUM(key5_1) as key5_1,
|
||||
SUM(key5_2) as key5_2,
|
||||
SUM(key2_1) as key2_1,
|
||||
SUM(key2_2) as key2_2,
|
||||
SUM(key2_3) as key2_3
|
||||
FROM country_keypress_reports
|
||||
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)
|
||||
FROM country_keypress_reports
|
||||
");
|
||||
|
||||
return $this->successResponse($data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user