Skip to content

Commit

Permalink
docs: add sample code for usage ResponseTrait in
Browse files Browse the repository at this point in the history
  • Loading branch information
datamweb committed Aug 19, 2024
1 parent f3ad32a commit e7e61bf
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions user_guide_src/source/outgoing/api_responses/018.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Libraries;

use CodeIgniter\API\ResponseTrait;
use CodeIgniter\HTTP\Response;

class MyCustomClass
{
use ResponseTrait;

protected Response $response;

public function __construct()
{
// Manually create a Response object
$this->response = service('response');
}

public function createUser()
{
return $this->respondCreated(['message' => 'User created.']);
}
}

0 comments on commit e7e61bf

Please sign in to comment.