<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Statement;

use Psy\Readline\Hoa\Console;

class AdminController extends Controller
{
    public function adminpanel()
{
    $states = Statement::orderBy('id', 'desc')->simplePaginate(3); 
    return view('adminpanel', ['states' => $states]);
}

    public function status($id, Request $request)
    {
        $state = Statement::where('id', $id)->first();
        if($request->route()->getName() == 'false'){
            $state->status = "Отклонено";
        }
        else{
            $state->status = "Принято";
        }
        $state->save();
        return redirect()->route('adminpanel');
    }
}
