<?php

declare(strict_types=1);

namespace App\Policies;

use App\Models\Setting;
use App\Models\User;

class SettingPolicy
{
    public function viewAny(?User $user): bool
    {
        return true;
    }

    public function view(?User $user, Setting $setting): bool
    {
        if ($setting->is_public) {
            return true;
        }

        return $user !== null && $user->hasRole('admin');
    }

    public function create(User $user): bool
    {
        return $user->hasRole('admin');
    }

    public function update(User $user, Setting $setting): bool
    {
        return $user->hasRole('admin');
    }

    public function delete(User $user, Setting $setting): bool
    {
        return $user->hasRole('admin');
    }

    public function restore(User $user, Setting $setting): bool
    {
        return $user->hasRole('admin');
    }

    public function forceDelete(User $user, Setting $setting): bool
    {
        return $user->hasRole('admin');
    }
}
