HEX
Server: LiteSpeed
System: Linux premium260.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
User: aliazzsr (627)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/aliazzsr/api.crm.vqode.com/controllers/CompanyController.php
<?php
namespace app\controllers;

use app\components\BaseActiveController;
use app\models\enums\PermissionEnum;

class CompanyController extends BaseActiveController
{
    public $modelClass = 'app\models\core\Company';

    protected static $permissionRequired = PermissionEnum::COMPANIES_ALL;

    public function actions()
    {
        $actions = parent::actions();

        $actions['first-letters'] = [
            'class' => 'app\components\actions\FirstLetterAction',
            'modelClass' => $this->modelClass,
            'checkAccess' => [$this, 'checkAccess'],
        ];

        return $actions;
    }
}
/**
 * @SWG\Get(
 *   path="/companies?expand={models}",
 *   tags={"Companies"},
 *   security={{"bearer":{}}},
 *   summary="Finds Company records existing.",
 *     consumes={"application/json"},
 *     produces={"application/json"},
 *   @SWG\Parameter(in="path", name="models", type="string",
 *     description="List of relative to Company models comma-separated. Available: companyType, owner, companyContacts, projects"
 *   ),
 *   @SWG\Response(response=200, description="Successful operation.",
 *     @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/Company"))
 *   ),
 *   @SWG\Response(response=401, description="Unauthorized."),
 *   @SWG\Response(response=422, description="Data validation error."),
 *   @SWG\Response(response=500, description="Internal server error.")
 * )
 *
 * @SWG\Get(
 *   path="/companies/first-letters",
 *   tags={"Companies"},
 *   security={{"bearer":{}}},
 *   summary="Lists first letter of companies names.",
 *     consumes={"application/json"},
 *     produces={"application/json"},
 *   @SWG\Response(response=200, description="Successful operation.",
 *     @SWG\Schema(type="array", @SWG\Items(type="string"))
 *   ),
 *   @SWG\Response(response=401, description="Unauthorized."),
 *   @SWG\Response(response=500, description="Internal server error.")
 * )
 *
 * @SWG\Get(
 *   path="/companies/{id}",
 *   tags={"Companies"},
 *   security={{"bearer":{}}},
 *   summary="Returns a single Company record.",
 *     consumes={"application/json"},
 *     produces={"application/json"},
 *   @SWG\Parameter(description="Uniques identifier", in="path", name="id", required=true, type="integer"),
 *   @SWG\Response(response=200, description="Successful operation.", @SWG\Schema(ref="#/definitions/Company")),
 *   @SWG\Response(response=401, description="Unauthorized."),
 *   @SWG\Response(response=404, description="Not found."),
 *   @SWG\Response(response=500, description="Internal server error.")
 * )
 *
 * @SWG\Post(
 *   path="/companies",
 *   tags={"Companies"},
 *   security={{"bearer":{}}},
 *   summary="Creates a new Company record.",
 *     consumes={"application/json"},
 *     produces={"application/json"},
 *   @SWG\Parameter(name="body", required=true, in="body", @SWG\Schema(
 *     ref="#/definitions/Company", required={"name"}
 *    )),
 *   @SWG\Response(response=201, description="Successful operation."),
 *   @SWG\Response(response=401, description="Unauthorized."),
 *   @SWG\Response(response=422, description="Data validation error."),
 *   @SWG\Response(response=500, description="Internal server error.")
 * )
 *
 * @SWG\Post(
 *   path="/companies/validate",
 *   tags={"Companies"},
 *   security={{"bearer":{}}},
 *   summary="Validates a new Company record.",
 *     consumes={"application/json"},
 *     produces={"application/json"},
 *   @SWG\Parameter(name="body", required=true, in="body", @SWG\Schema(
 *     ref="#/definitions/Company", required={"name"}
 *    )),
 *   @SWG\Response(response=201, description="Successful operation."),
 *   @SWG\Response(response=401, description="Unauthorized."),
 *   @SWG\Response(response=422, description="Data validation error."),
 *   @SWG\Response(response=500, description="Internal server error.")
 * )
 *
 * @SWG\Post(
 *   path="/companies/{id}/validate",
 *   tags={"Companies"},
 *   security={{"bearer":{}}},
 *   summary="Validates an existed Company record.",
 *     consumes={"application/json"},
 *     produces={"application/json"},
 *   @SWG\Parameter(description="Unique identifier", in="path", name="id", required=true, type="integer"),
 *   @SWG\Parameter(name="body", required=true, in="body", @SWG\Schema(
 *     ref="#/definitions/Company", required={"name"}
 *    )),
 *   @SWG\Response(response=201, description="Successful operation."),
 *   @SWG\Response(response=401, description="Unauthorized."),
 *   @SWG\Response(response=422, description="Data validation error."),
 *   @SWG\Response(response=500, description="Internal server error.")
 * )
 *
 * @SWG\Put(
 *   path="/companies/{id}",
 *   tags={"Companies"},
 *   security={{"bearer":{}}},
 *   summary="Updates an existed Company record.",
 *     consumes={"application/json"},
 *     produces={"application/json"},
 *   @SWG\Parameter(description="Unique identifier", in="path", name="id", required=true, type="integer"),
 *   @SWG\Parameter(name="body", required=true, in="body", @SWG\Schema(
 *     ref="#/definitions/Company")),
 *   @SWG\Response(response=401, description="Unauthorized."),
 *   @SWG\Response(response=422, description="Data validation error."),
 *   @SWG\Response(response=500, description="Internal server error.")
 * )
 *
 * @SWG\Delete(
 *   path="/companies/{id}",
 *   tags={"Companies"},
 *   security={{"bearer":{}}},
 *   summary="Deletes a Company record.",
 *     consumes={"application/json"},
 *     produces={"application/json"},
 *   @SWG\Parameter(description="Uniques identifier", in="path", name="id", required=true, type="integer"),
 *   @SWG\Response(response=204, description="Successful operation."),
 *   @SWG\Response(response=401, description="Unauthorized."),
 *   @SWG\Response(response=404, description="Not found."),
 *   @SWG\Response(response=500, description="Internal server error.")
 * )
 */