# erp/1.3.13/modules/hrm/includes/api/class-hrm-company-controller.php

ERP: Complete HR, Accounting &amp; CRM Suite Built for WooCommerce, version 1.3.13. 175 lines.

- Page: https://pluginprobe.com/plugins/erp/1.3.13/code/modules/hrm/includes/api/class-hrm-company-controller.php
- Raw: https://pluginprobe.com/plugins/erp/1.3.13/raw/modules/hrm/includes/api/class-hrm-company-controller.php
- Modified: 2018-09-03T08:36:42+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/erp/1.3.13/code/modules/hrm/includes/api/class-hrm-company-controller.php#L10-L20`.

```php
<?php

namespace WeDevs\ERP\HRM\API;

use WP_REST_Server;
use WP_REST_Response;
use WP_Error;
use WeDevs\ERP\API\REST_Controller;

class Company_Controller extends REST_Controller {
    /**
     * Endpoint namespace.
     *
     * @var string
     */
    protected $namespace = 'erp/v1';

    /**
     * Route base.
     *
     * @var string
     */
    protected $rest_base = 'hrm/company';

    /**
     * Register the routes for the objects of the controller.
     */
    public function register_routes() {
        register_rest_route( $this->namespace, '/' . $this->rest_base . '/company-locations', [
            [
                'methods'             => WP_REST_Server::READABLE,
                'callback'            => [ $this, 'get_company_locations' ],
                'args'                => $this->get_collection_params(),
                'permission_callback' => function ( $request ) {
                    return current_user_can( 'erp_view_list' );
                },
            ],
            'schema' => [ $this, 'get_public_item_schema' ],
        ] );

        register_rest_route( $this->namespace, '/' . $this->rest_base . '/employee-statuses', [
            [
                'methods'             => WP_REST_Server::READABLE,
                'callback'            => [ $this, 'get_employee_statuses' ],
                'args'                => $this->get_collection_params(),
                'permission_callback' => function ( $request ) {
                    return current_user_can( 'erp_list_employee' );
                },
            ],
            'schema' => [ $this, 'get_public_item_schema' ],
        ] );

        register_rest_route( $this->namespace, '/' . $this->rest_base . '/employee-types', [
            [
                'methods'             => WP_REST_Server::READABLE,
                'callback'            => [ $this, 'get_employee_types' ],
                'args'                => $this->get_collection_params(),
                'permission_callback' => function ( $request ) {
                    return current_user_can( 'erp_view_list' );
                },
            ],
            'schema' => [ $this, 'get_public_item_schema' ],
        ] );

        register_rest_route( $this->namespace, '/' . $this->rest_base . '/pay-types', [
            [
                'methods'             => WP_REST_Server::READABLE,
                'callback'            => [ $this, 'get_employee_pay_types' ],
                'args'                => $this->get_collection_params(),
                'permission_callback' => function ( $request ) {
                    return current_user_can( 'erp_view_list' );
                },
            ],
            'schema' => [ $this, 'get_public_item_schema' ],
        ] );
        register_rest_route( $this->namespace, '/' . $this->rest_base . '/hiring-sources', [
            [
                'methods'             => WP_REST_Server::READABLE,
                'callback'            => [ $this, 'get_source_of_hire' ],
                'args'                => $this->get_collection_params(),
                'permission_callback' => function ( $request ) {
                    return current_user_can( 'erp_view_list' );
                },
            ],
            'schema' => [ $this, 'get_public_item_schema' ],
        ] );
    }

    /**
     * Get company locations
     *
     * @since 1.3.2
     *
     * @param $request
     *
     * @return mixed|object|\WP_REST_Response
     */
    public function get_company_locations( $request ) {
        $locations = erp_company_get_locations();
        $response  = rest_ensure_response( $locations );
        $response  = $this->format_collection_response( $response, $request, count( $locations ) );

        return $response;
    }

    /**
     * Get employee statuses
     *
     * @since 1.3.2
     *
     * @param $request
     *
     * @return mixed|object|\WP_REST_Response
     */
    public function get_employee_statuses( $request ) {
        $statuses = erp_hr_get_employee_statuses();
        $response = rest_ensure_response( $statuses );
        $response = $this->format_collection_response( $response, $request, count( $statuses ) );

        return $response;
    }

    /**
     * Get employee pay types
     *
     * @since 1.3.2
     *
     * @param $request
     *
     * @return mixed|object|\WP_REST_Response
     */
    public function get_employee_pay_types( $request ) {
        $pay_types = erp_hr_get_pay_type();
        $response  = rest_ensure_response( $pay_types );
        $response  = $this->format_collection_response( $response, $request, count( $pay_types ) );

        return $response;
    }

    /**
     * Get employee types
     *
     * @since 1.3.2
     *
     * @param $request
     *
     * @return mixed|object|\WP_REST_Response
     */
    public function get_employee_types( $request ) {
        $employee_types = erp_hr_get_employee_types();
        $response       = rest_ensure_response( $employee_types );
        $response       = $this->format_collection_response( $response, $request, count( $employee_types ) );

        return $response;
    }

    /**
     * Get hiring source
     *
     * @since 1.3.2
     *
     * @param $request
     *
     * @return mixed|object|\WP_REST_Response
     */
    public function get_source_of_hire( $request ) {
        $sources  = erp_hr_get_employee_sources();
        $response = rest_ensure_response( $sources );
        $response = $this->format_collection_response( $response, $request, count( $sources ) );

        return $response;
    }

}

```
