prefix code and write route
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\V3\Mission\Report\Tradod;
|
||||
namespace App\Exports\V3\Mission\Report\Machine;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
@@ -24,7 +24,7 @@ class machineReport implements FromView, ShouldAutoSize, WithDrawings, WithEvent
|
||||
$exportRows[] = [
|
||||
'city_name' => $r->c_name ?? '',
|
||||
'province_name' => $r->p_name ?? '',
|
||||
'm_c_code' => $r->m_c_code ?? 0,
|
||||
'missions' => $r->missions ?? 0,
|
||||
'distance' => (int) ($r->distance ?? 0),
|
||||
];
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\V3\Dashboard\Mission\Report;
|
||||
|
||||
use App\Exports\V3\Mission\Report\Tradod\CountryReport;
|
||||
use App\Exports\V3\Mission\Report\Tradod\machineReport;
|
||||
use App\Exports\V3\Mission\Report\Tradod\ProvinceReport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
@@ -21,14 +22,11 @@ class ReportMachineController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function Activity(Request $request, ReportMachineService $reportMachineService): JsonResponse
|
||||
public function activity(Request $request, ReportMachineService $reportMachineService): JsonResponse
|
||||
{
|
||||
return $this->successResponse([
|
||||
'activities' => $reportMachineService->Activity($request),
|
||||
'provinces' => Province::all(['id', 'name_fa']),
|
||||
'code' => Mission::query()
|
||||
->where('machine_code', $request->machine_code)
|
||||
->get()
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -36,12 +34,12 @@ class ReportMachineController extends Controller
|
||||
* @throws Exception
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
||||
*/
|
||||
public function ExcelActivity(Request $request, ReportMachineService $reportMachineService): BinaryFileResponse
|
||||
public function excelActivity(Request $request, ReportMachineService $reportMachineService): BinaryFileResponse
|
||||
{
|
||||
$data = $reportMachineService->Activity($request);
|
||||
$name = 'گزارش کل تردد یک ماشین '.verta()->now()->format('Y-m-d H-i').'.xlsx';
|
||||
|
||||
return Excel::download(new CountryReport($data), $name);
|
||||
return Excel::download(new machineReport($data), $name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ class FinishRequest extends FormRequest
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$mission = $this->route('mission');
|
||||
return [
|
||||
'time' => 'required|date',
|
||||
'end_km' => 'required',
|
||||
@@ -35,7 +34,7 @@ class FinishRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
function (Validator $validator) {
|
||||
$mission = $this->route('mission');
|
||||
$mission = $this->mission;
|
||||
if (strtotime($this->time) < strtotime($mission->start_time)) {
|
||||
$validator->errors()->add(
|
||||
'time',
|
||||
|
||||
@@ -22,16 +22,13 @@ class ReportMachineService
|
||||
m.city_id AS c_id,
|
||||
m.province_name AS p_name,
|
||||
m.province_id AS p_id,
|
||||
COUNT(m.machine_code) As m_c_code,
|
||||
SUM(m.end_km)-sum(m.km) AS distance
|
||||
COUNT(m.id) As missions,
|
||||
(SUM(m.end_km)-SUM(m.km)) AS distance
|
||||
|
||||
FROM missions m
|
||||
WHERE m.machine_code = :machineCode
|
||||
AND m.created_at >= :from
|
||||
AND m.created_at <= :to
|
||||
GROUP BY m.city_id, m.city_name,m.province_id, m.province_name;
|
||||
|
||||
|
||||
AND m.created_at <= :to;
|
||||
";
|
||||
|
||||
return DB::select($sql, [
|
||||
|
||||
Reference in New Issue
Block a user