Files
cheerstothe_season_2.0/app/Http/Controllers/Admin/ManageFeedbackController.php
2024-06-18 13:18:04 +05:30

59 lines
1.4 KiB
PHP

<?php
namespace App\Http\Controllers\Admin;
use App\Exports\FeedbakExport;
use App\Http\Controllers\Controller;
use App\Models\ManageFeedback;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;
class ManageFeedbackController extends Controller
{
/**
* Created By : sayali parab
* Created at : 17 May 2024
* Use : To get manage feedback page.
*/
public function index()
{
$feedback = ManageFeedback::with('principal', 'feedbackReaction','restaurant')
->orderBy('created_at', 'desc')
->get();
return view('Admin.pages.manage_feedback.manage_feedback', compact('feedback'));
}
/**
* Created By : Sayli Raut
* Created at : 10 June 2024
* Use : To delete query.
*/
public function delete_feedback($id)
{
$data = ManageFeedback::find($id)->delete();
return redirect()->back()->with('success', '');
}
/*
Created By : Sayli Raut
Created at : 17 June 2024
Use : To download Excel.
*/
public function exportSelectedFeedback(Request $request)
{
// dd($request->all());
try {
if ($request->has('all_id')) {
return Excel::download(new FeedbakExport, 'Feedback_data.xlsx');
}
} catch (\Exception $e) {
return response()->json(['error' => 'Export failed. Something went wrong.'], 500);
}
}
}