<?php

namespace App\Http\Controllers\Admin;

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

class ManageRulesController extends Controller
{
    /**
     * Created By : sayli Raut
     * Created at : 19 June 2024
     * Use : To view Rules page.
     */
    public function index()
    {
        $data = ManageRule::all()->toArray();
        return view('Admin.pages.manage_rule.manage_rule', compact('data'));
    }

    /**
     * Created By : sayli Raut
     * Created at : 19 June 2024
     * Use : To edit Rules.
     */
    public function edit($id)
    {
        $data = ManageRule::find($id);
        return view('Admin.pages.manage_rule.manage_rules_edit', compact('data'));
    }

    /**
     * Created By : sayli Raut
     * Created at : 19 June 2024
     * Use : To update Rules.
     */
    public function update(Request $request)
    {

        $validated = $request->validate([

            'article_des' => 'required',
        ]);
        $update = ManageRule::find($request->rule_id);
        $update->message = $request->input('article_des');
        $update->save();
        return response()->json(['success' => true, 'status' => 200]);
    }
}
