<?php

namespace App\Modules\Settings\Localization\Policies;

use App\Models\User;
use App\Modules\Settings\Localization\Models\Language;

class LanguagePolicy
{
    public function viewAny(User $user): bool
    {
        return $user->can('languages.view');
    }

    public function view(User $user, Language $language): bool
    {
        return $user->can('languages.view');
    }

    public function create(User $user): bool
    {
        return $user->can('languages.create');
    }

    public function update(User $user, Language $language): bool
    {
        return $user->can('languages.update', $language);
    }

    public function delete(User $user, Language $language): bool
    {
        if (! $user->can('languages.delete', $language)) {
            return false;
        }

        return ! $language->is_default;
    }
}
