45 lines
1016 B
PHP
45 lines
1016 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\RekomendasiUser;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class UserLaporanController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$laporans = RekomendasiUser::where('user_id', Auth::id())
|
|
->latest()
|
|
->get();
|
|
|
|
return view('user.laporan.index', compact('laporans'));
|
|
}
|
|
|
|
public function show($id)
|
|
{
|
|
$laporan = RekomendasiUser::where('user_id', Auth::id())
|
|
->findOrFail($id);
|
|
|
|
$detail = json_decode($laporan->hasil_json, true);
|
|
|
|
return view('user.laporan.show', compact(
|
|
'laporan',
|
|
'detail'
|
|
));
|
|
}
|
|
|
|
public function destroy($id)
|
|
{
|
|
$laporan = RekomendasiUser::where(
|
|
'user_id',
|
|
auth()->id()
|
|
)->findOrFail($id);
|
|
|
|
$laporan->delete();
|
|
|
|
return redirect()
|
|
->route('user.laporan.index')
|
|
->with('success', 'Riwayat rekomendasi berhasil dihapus.');
|
|
}
|
|
} |