<?php

namespace Mehrab\User\Policies;

use Illuminate\Auth\Access\HandlesAuthorization;
use Mehrab\RolePermission\Models\Permission;
use Mehrab\User\Models\User;

class UserPolicy
{
    use HandlesAuthorization;

    /**
     * Create a new policy instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    public function manage(User $user){
        return $user->hasPermissionTo(Permission::PERMISSION_MANAGE_USER);
    }

    public function create(User $user){
        return $user->hasPermissionTo(Permission::PERMISSION_MANAGE_USER);
    }

    public function edit(User $user){
        return $user->hasPermissionTo(Permission::PERMISSION_MANAGE_USER);
    }

    public function edit_role(User $user){
        return $user->hasPermissionTo(Permission::PERMISSION_MANAGE_USER);
    }

    public function status(User $user){
        return $user->hasPermissionTo(Permission::PERMISSION_MANAGE_USER);
    }

    public function status_available(User $user){
        return $user->hasAnyPermission([Permission::PERMISSION_EXPERT,Permission::PERMISSION_TEAM_LEADER,Permission::PERMISSION_ORDER_SERVICE_OPERATOR,]);
    }

    public function manage_expert(User $user){
        return $user->hasPermissionTo(Permission::PERMISSION_MANAGE_EXPERT);
    }

    public function manage_team_leaders(User $user){
        return $user->hasPermissionTo(Permission::PERMISSION_MANAGE_TEAM_LEADER);
    }

    public function set_address(User $user){
            return true;
    }

    public function panel_index(User $user){
        return $user->hasPermissionTo(Permission::PERMISSION_USER);
    }

}
