<?php

namespace App\Http\Controllers\Admin;

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

class PrivacyPolicyController extends Controller
{
    
    // public function index(){

    //     return view('Admin.pages.manage_cms.manage_privacy.manage_privacy');
    // }
    // public function index(){
    //     $view_privacy_policy = PrivacyPolicy::get()->toArray();
    //     // dd($view_privacy_policy);
    //     return view('Admin.pages.manage_cms.manage_privacy.manage_privacy');
    // }

  /**
    * Created By : sayali parab
    * Created at : 29 May 2024
    * Use : To get privacy policy page.
    */
    public function index(){
        $view_privacy = PrivacyPolicy::get()->toArray();
        return view('Admin.pages.manage_cms.manage_privacy.manage_privacy', compact('view_privacy'));
    }
    
  /**
    * Created By : sayali parab
    * Created at : 29 May 2024
    * Use : To edit.
    */
    public function edit($id)
    {
        $edit_privacy_policy = PrivacyPolicy::find($id)->toArray();
        return view('Admin.pages.manage_cms.manage_privacy.manage_privacy_policy_edit', compact('edit_privacy_policy'));
    }

      /**
    * Created By : sayali parab
    * Created at : 29 May 2024
    * Use : To update privacy policy page.
    */
    public function update(Request $request)
    {
        $update = PrivacyPolicy::find($request->privacy_custom_id);
        $update->description = $request->input('privacy_policy');
        $update->save();
        return response()->json(['success' => true, 'status' => 200]);
    }

    /**
    * Created By : sayali parab
    * Created at : 29 May 2024
    * Use : To edit rest.
    */
    public function edit_rest($id)
    {
        $edit_privacy_policy_rest = PrivacyPolicy::find($id)->toArray();
        return view('Admin.pages.manage_cms.manage_privacy.manage_privacy_policy_edit_rest', compact('edit_privacy_policy_rest'));
    }
     /**
    * Created By : sayali parab
    * Created at : 30 May 2024
    * Use : To update rest.
    */
    public function update_rest(Request $request)
    {
        $update = PrivacyPolicy::find($request->privacy_rest_id);
        $update->description = $request->input('edit_privacy_policy_rest');
        $update->save();
        return response()->json(['success' => true, 'status' => 200]);
    }
    
}
