fix: update admin dashboard
This commit is contained in:
@@ -10,6 +10,11 @@ use App\Models\Flight;
|
|||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\Tour;
|
use App\Models\Tour;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use App\Exports\VisitsExport;
|
||||||
|
use App\Models\VisitStatistic;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Hekmatinasser\Verta\Verta;
|
||||||
|
|
||||||
class DashboardController extends Controller
|
class DashboardController extends Controller
|
||||||
{
|
{
|
||||||
@@ -39,4 +44,25 @@ class DashboardController extends Controller
|
|||||||
'paymentsCount'
|
'paymentsCount'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function exportExcel()
|
||||||
|
{
|
||||||
|
// ۱. لیست کاربران با فیلدهایی که واقعاً در جدول users داری
|
||||||
|
$users = User::select('id', 'first_name', 'last_name', 'email', 'mobile', 'created_at')->get();
|
||||||
|
|
||||||
|
|
||||||
|
// ۲. تبدیل به آرایه برای اکسل
|
||||||
|
$rows = $users->map(fn($user) => [
|
||||||
|
$user->id,
|
||||||
|
$user->first_name,
|
||||||
|
$user->last_name,
|
||||||
|
$user->email,
|
||||||
|
$user->mobile,
|
||||||
|
$user->created_at ? Verta::instance($user->created_at)->format('Y/m/d') : '-',
|
||||||
|
])->toArray();
|
||||||
|
|
||||||
|
// ۳. تغییر کلاس اکسل و اسم فایل
|
||||||
|
return Excel::download(new VisitsExport($rows), 'users-report-' . now()->format('Y-m-d') . '.xlsx');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user