acelords/generators

AceLords Generators

1.1.7 2023-02-01 13:26 UTC

This package is auto-updated.

Last update: 2024-08-29 16:49:01 UTC


README

AceLords composer 包,用于 AceLords 项目。

命令

acelords:make-channel             Create a new AceLords project channel class
acelords:make-command             Create a new AceLords project command
acelords:make-controller          Create a new AceLords project controller class
acelords:make-controller --api    Create a new AceLords project controller class containing only the api methods
acelords:make-controller --repo   Create a new AceLords project controller class based on a model repository
acelords:make-event               Create a new AceLords project event class
acelords:make-facade              Create a new AceLords project facade class
acelords:make-filter              Create a new AceLords project filter class
acelords:make-job --sync          Create a new AceLords project job class
acelords:make-listener --queued   Create a new AceLords project event listener class
acelords:make-mail                Create a new AceLords project email class
acelords:make-middleware          Create a new AceLords project middleware class
acelords:make-model               Create a new AceLords project Eloquent model class
acelords:make-notification        Create a new AceLords project notification class
acelords:make-policy              Create a new AceLords project policy class
acelords:make-project             Craft a new AceLords project under packages
acelords:make-provider            Create a new AceLords project service provider class
acelords:make-repo                Create a new AceLords project event class
acelords:make-request             Create a new AceLords project form request class
acelords:make-resource            Create a new AceLords project resource
acelords:make-rule                Create a new AceLords project validation rule
acelords:make-service             Create a new AceLords project service class for a facade class
acelords:make-widget              Create a new AceLords project widget class

如何运行

// create a UserController in users module
php artisan acelords:make-controller UserController users

安装

可以通过 composer 安装

composer install acelords/generators

响应方法

将这些方法添加到基础 Controller 中将有助于更容易地进行修改

/**
     * return a standardized error message
     *
     * @param string $message
     * @param int $code
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function respError($message = 'An error occurred', $code = 422)
    {
        return response()->json([
            'message' => $message,
            'alert' => 'error',
        ], $code);
    }

    /**
     * return a standardized success message
     *
     * @param string $message
     * @param int $code
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function respSuccess($message = 'Action Successful', $code = 200)
    {
        return response()->json([
            'message' => $message,
            'alert' => 'success',
        ], $code);
    }

    /**
     * provide a common function to return messages to the user
     *
     * @param $result
     * @param string $messageOnSuccess
     * @param string $messageOnError
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function respJuicer($result, $messageOnSuccess = 'Action Successful', $messageOnError = 'An error occurred')
    {
        if($result)
            return $this->respSuccess($messageOnSuccess);

        return $this->respError($messageOnError);
    }

支持

如果您觉得这个包很有用,并愿意为维护者买杯咖啡(或者一辆特斯拉,我们不会挑剔),请随意。

众筹

您也可以在 Github SponsorsPatreon 或者在 市场 购买产品和支持项目。

这些资金用于维护项目,向代码风格添加新功能,以及其他开源代码库。

许可证

许可协议:DBAD

鸣谢