How does Dingo/Api return a custom status code when it is successful?

how does Dingo/Api return a custom status code in a successful state?

recently, a new version of API, has introduced Dingo/api, into laravel. Due to business needs, when you successfully return data, you can also bring status code and prompt message . The structure is as follows:

{
    status_code: 200,
    msg: "success",
    data:[...],
    ...
}

its practical laravel response ()-> json () can also be mixed, but I still want to use the feature of Dingo/api when returning the result, and can add other data, please guide the students who have practiced it.

Apr.01,2021

just use the setStatusCode method

response ()-> json ()-> setStatusCode


refer to exception handling:
if you customize exception handling:
https://laravel-china.org/doc.
setting status value is relatively simple

$result = [
        'captcha_key' => $cache_key,
        'captcha_content' => $captcha->inline(),
        'captcha_expire_at' => $expired_at,
        'code' => $code
    ];

    return $this->response->array($result)->setStatusCode(201);
    
reference link: [Dingo API 2.0.0 Chinese documentation] [1]
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e37268-430ce.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e37268-430ce.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?