<?php

namespace Modules\User\Policies;

use Illuminate\Auth\Access\HandlesAuthorization;
use Modules\Auth\Entities\User;

class UserPolicy
{
    use HandlesAuthorization;

    /**
     * Determine whether the user can view any models.
     */
    public function viewAny($user): bool
    {
        return $user->hasPermissionTo('lihat pengguna');
    }

    /**
     * Determine whether the user can view the model.
     */
    public function view($user, ?User $userModel = null): bool
    {
        return $user->hasPermissionTo('lihat pengguna');
    }

    /**
     * Determine whether the user can create models.
     */
    public function create($user): bool
    {
        return $user->hasPermissionTo('daftar pengguna baru');
    }

    /**
     * Determine whether the user can update the model.
     */
    public function update($user, ?User $userModel = null): bool
    {
        return $user->hasPermissionTo('kemaskini pengguna');
    }

    /**
     * Determine whether the user can delete any model.
     */
    public function deleteAny($user): bool
    {
        return $user->hasPermissionTo('padam akaun pengguna');
    }

    /**
     * Determine whether the user can delete the model.
     */
    public function delete($user, ?User $userModel = null): bool
    {
        return $user->hasPermissionTo('padam akaun pengguna');
    }

    /**
     * Determine whether the user can restore a soft-deleted model.
     */
    public function restore($user, ?User $userModel = null): bool
    {
        return $user->hasPermissionTo('padam akaun pengguna');
    }
}
