22
33namespace App \Controllers \Api ;
44
5- use CodeIgniter \Api \ResponseTrait ;
65use App \Controllers \BaseController ;
76use App \Transformers \BookTransformer ;
7+ use CodeIgniter \Api \ResponseTrait ;
88
99class Books extends BaseController
1010{
@@ -20,14 +20,14 @@ class Books extends BaseController
2020 */
2121 public function getIndex (?int $ id = null )
2222 {
23- $ model = model ('BookModel ' );
23+ $ model = model ('BookModel ' );
2424 $ transformer = new BookTransformer ();
2525
2626 // If an ID is provided, fetch a single record
2727 if ($ id !== null ) {
2828 $ book = $ model ->withAuthorInfo ()->find ($ id );
2929
30- if (!$ book ) {
30+ if (! $ book ) {
3131 return $ this ->failNotFound ('Book not found ' );
3232 }
3333
@@ -47,7 +47,7 @@ public function getIndex(?int $id = null)
4747 */
4848 public function putIndex (int $ id )
4949 {
50- $ data = $ this ->request ->getRawInput ();
50+ $ data = $ this ->request ->getRawInput ();
5151 $ model = model ('BookModel ' );
5252
5353 $ rules = [
@@ -56,13 +56,13 @@ public function putIndex(int $id)
5656 'year ' => 'required|integer|greater_than_equal_to[2000]|less_than_equal_to[ ' . date ('Y ' ) . '] ' ,
5757 ];
5858
59- if (!$ this ->validate ($ rules )) {
59+ if (! $ this ->validate ($ rules )) {
6060 return $ this ->failValidationErrors ($ this ->validator ->getErrors ());
6161 }
6262
6363 $ model = model ('BookModel ' );
6464
65- if (!$ model ->find ($ id )) {
65+ if (! $ model ->find ($ id )) {
6666 return $ this ->failNotFound ('Book not found ' );
6767 }
6868
@@ -88,7 +88,7 @@ public function postIndex()
8888 'year ' => 'required|integer|greater_than_equal_to[2000]|less_than_equal_to[ ' . date ('Y ' ) . '] ' ,
8989 ];
9090
91- if (!$ this ->validate ($ rules )) {
91+ if (! $ this ->validate ($ rules )) {
9292 return $ this ->failValidationErrors ($ this ->validator ->getErrors ());
9393 }
9494
@@ -109,7 +109,7 @@ public function deleteIndex(int $id)
109109 {
110110 $ model = model ('BookModel ' );
111111
112- if (!$ model ->find ($ id )) {
112+ if (! $ model ->find ($ id )) {
113113 return $ this ->failNotFound ('Book not found ' );
114114 }
115115
0 commit comments