<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\MarkList;

class AdminMarkListController extends Controller
{
    /**
     * Show all mark list entries in descending order (latest first)
     */
    public function index()
    {
        $markList = MarkList::orderBy('id', 'desc')->get();

        return view('admin.mark_list', compact('markList'));
    }

    /**
     * Toggle status between Active and Inactive
     */
    public function toggleStatus($id)
    {
        $mark = MarkList::findOrFail($id);

        // Toggle logic
        $mark->status = $mark->status === 'active' ? 'inactive' : 'active';
        $mark->save();

        return redirect()->back()->with('success', 'Status updated successfully!');
    }
}
