<?php

namespace App\Http\Controllers\Admin;

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

class HeroThreeController extends Controller
{
    function __construct()
    {
        $this->middleware('role_or_permission:homepage hero3 update', ['only' => ['index','update']]);
    }

    function index()
    {
        $data = HeroThree::first();
        return view('admin.home.herothree.index', compact('data'));
    }


    function update(Request $request)
    {
        $request->validate([
            'title' => 'nullable',
            'description' => 'nullable'
        ]);

        HeroThree::query()->updateOrCreate([
            'id' => 1
        ], $request->all());

        $notification = array(
            'messege' => 'Created successfully',
            'alert-type' => 'success'
        );

        return back()->with($notification);
    }
}
