%PDF- %PDF-
Direktori : /home/silvzytp/crm-ind-code/app/Http/Controllers/Backend/ |
Current File : //home/silvzytp/crm-ind-code/app/Http/Controllers/Backend/ReportController.php |
<?php namespace App\Http\Controllers\Backend; use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use App\Http\Controllers\Controller; use Maatwebsite\Excel\Facades\Excel; use Maatwebsite\Excel\Concerns\FromView; use Illuminate\Contracts\View\View; class ReportController extends Controller { public function report(){ $agents = DB::table('users')->select('id','name')->where('role_id',4)->get(); $sources = DB::table('marketing_sources')->select('id','name')->where('status',1)->get(); $month = Carbon::now()->format('m'); page_title('Reports'); // breadcrumb $breadcrumb = ['Dashboard'=>route('super.dashboard'),'Reports'=>'']; return view('backend.report.index', compact('breadcrumb','agents','sources','month')); } public function report_filter(Request $request){ if ($request->ajax()) { $year = (int)$request->year; $month = $request->month; $agents = DB::table('users')->select('id','name')->where('role_id',4)->get(); $sources = DB::table('marketing_sources')->select('id','name')->where('status',1)->get(); $data = view('backend.report.filter', compact('agents','sources','month','year'))->render(); return response()->json($data); } } public function report_export(Request $request){ return Excel::download(new class implements FromView { public function view(): View{ $data = request()->all(); $year = (int)$data['year']; $month = $data['month']; $agents = DB::table('users')->select('id','name')->where('role_id',4)->get(); $sources = DB::table('marketing_sources')->select('id','name')->where('status',1)->get(); return view('backend.report.filter', compact('agents','sources','month','year')); } }, date('d-m-Y').'-report.xlsx'); } }