<?php
namespace BooklyStaffCabinet\Frontend\Modules\StaffDetails;

use Bookly\Lib as BooklyLib;

/**
 * Class Ajax
 * @package BooklyStaffCabinet\Frontend\Modules\StaffDetails
 */
class Ajax extends BooklyLib\Base\Ajax
{
    /**
     * @inheritdoc
     */
    protected static function permissions()
    {
        return array(
            'getDetails' => 'user',
        );
    }

    public static function getDetails()
    {
        $attributes = self::parameter( 'attributes' );
        $staff = BooklyLib\Entities\Staff::query()->where( 'wp_user_id', get_current_user_id() )->findOne();
        $hide  = isset ( $attributes['hide'] ) ? explode( ',', $attributes['hide'] ) : array();
        $html  = self::renderTemplate( 'details', compact( 'staff', 'hide' ), false );
        wp_send_json_success( compact( 'html' ) );
    }
}