trangshopeeaffiliate/app/Http/Controllers/Web/HistoryController.php
2026-07-11 22:56:22 +07:00

43 lines
1.3 KiB
PHP

<?php
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Services\HistoryService;
class HistoryController extends Controller
{
protected HistoryService $historyService;
public function __construct(HistoryService $historyService)
{
$this->historyService = $historyService;
}
public function index()
{
$histories = $this->historyService->getPaginated(20);
$allowedThreadIds = \App\Models\ZaloChannel::pluck('thread_id')->toArray();
return view('history.index', compact('histories', 'allowedThreadIds'));
}
public function destroy($id)
{
$history = \App\Models\ConversionHistory::findOrFail($id);
$history->delete();
return back()->with('success', 'Đã xoá lịch sử chuyển đổi thành công.');
}
public function bulkDestroy(\Illuminate\Http\Request $request)
{
$ids = $request->input('ids', []);
if (!empty($ids)) {
\App\Models\ConversionHistory::whereIn('id', $ids)->delete();
return back()->with('success', 'Đã xoá thành công ' . count($ids) . ' lịch sử chuyển đổi.');
}
return back()->with('error', 'Vui lòng chọn ít nhất một bản ghi để xoá.');
}
}