<?php

use Livewire\Component;
use App\Models\LegalPage;

return new class extends Component
{
    public LegalPage $page;
    public $content = '';

    public function render()
    {
        return $this->view()->layout('layouts::auth');
    }

    public function mount(LegalPage $page)
    {
        $this->page = $page;
        $this->content = $page->content;
    }

    public function save()
    {
        $this->validate([
            'content' => 'required',
        ]);

        $this->page->update([
            'content' => $this->content,
        ]);

        session()->flash('message', 'Legal page updated successfully.');
        return $this->redirect(route('admin.legal'), navigate: true);
    }

    protected function view($data = [])
    {
        return app('view')->file('D:\02-my freelance\00-DR_Padhi\DR_PADHI\storage\framework/views/livewire/views/632ca5ec.blade.php', $data);
    }
};
