@@ -169,7 +169,7 @@ protected function getApiDataField()
169
169
return $ this ->resource ->getApiDataField ();
170
170
}
171
171
172
- public function find ($ id , $ column ="" )
172
+ public function find ($ id , $ column ="" )
173
173
{
174
174
if (is_array ($ id )){
175
175
return $ this ->whereIn ($ id , $ column )->get (null , $ raw );
@@ -180,27 +180,27 @@ public function find($id, $column="")
180
180
]), "individual " , "allow " );
181
181
}
182
182
183
- public function findMany (array $ id , $ column ="" )
183
+ public function findMany (array $ id , $ column ="" )
184
184
{
185
185
return $ this ->whereIn ($ id , $ column )->get ();
186
186
}
187
187
188
- public function findOrFail ($ id )
188
+ public function findOrFail ($ id )
189
189
{
190
190
return $ this ->handleResponse ($ this ->sendRequest ('get ' , [
191
191
$ this ->retreiveEndPoint ('get ' ).'/ ' .$ id
192
192
]), "individual " , "error " );
193
193
}
194
194
195
- public function firstOrFail ()
195
+ public function firstOrFail ()
196
196
{
197
197
if (!is_null ($ model = $ this ->first ())){
198
198
return $ model ;
199
199
}
200
200
throw (new ModelNotFoundException )->setModel (get_class ($ this ->resource ));
201
201
}
202
202
203
- protected function processHeaders ()
203
+ protected function processHeaders ()
204
204
{
205
205
if ($ this ->asForm ){
206
206
$ this ->request ->asForm ();
@@ -210,7 +210,7 @@ protected function processHeaders()
210
210
}
211
211
}
212
212
213
- protected function processFiles ()
213
+ protected function processFiles ()
214
214
{
215
215
if ($ this ->files != []){
216
216
foreach ($ this ->files as $ key => $ file ){
@@ -238,7 +238,7 @@ public function handleResponse($response, $type="individual", $ifEmpty="default"
238
238
}
239
239
}
240
240
241
- public function handleRaw ($ response )
241
+ public function handleRaw ($ response )
242
242
{
243
243
if (!$ this ->throwExceptionsIfRaw ){
244
244
return $ response ;
@@ -249,7 +249,7 @@ public function handleRaw($response)
249
249
}
250
250
}
251
251
252
- public function handle404 ($ response , $ ifEmpty )
252
+ public function handle404 ($ response , $ ifEmpty )
253
253
{
254
254
if ($ ifEmpty == 'allow ' ){
255
255
return null ;
@@ -260,7 +260,7 @@ public function handle404($response, $ifEmpty)
260
260
}
261
261
}
262
262
263
- public function all ()
263
+ public function all ()
264
264
{
265
265
$ this ->setPerPageToMax ();
266
266
if ($ this ->resource ->beforeQuery ($ this ) === false ){
@@ -270,7 +270,7 @@ public function all()
270
270
$ this ->retreiveEndPoint ('get ' ),
271
271
$ this ->addPagination ($ this ->combineQueries ()),
272
272
]), 'all ' );
273
-
273
+
274
274
}
275
275
276
276
public function get ()
@@ -304,7 +304,7 @@ public function post($attributes, $type="individual")
304
304
$ this ->retreiveEndPoint ('post ' ),
305
305
$ attributes ,
306
306
$ this ->combineQueries ()
307
- ]), $ type );
307
+ ]), $ type. ' Post ' );
308
308
}
309
309
310
310
public function patch ($ attributes , $ type ="individual " )
@@ -316,7 +316,7 @@ public function patch($attributes, $type="individual")
316
316
$ this ->retreiveEndPoint ('patch ' ),
317
317
$ attributes ,
318
318
$ this ->combineQueries ()
319
- ]), $ type );
319
+ ]), $ type. ' Patch ' );
320
320
}
321
321
322
322
public function put ($ attributes , $ type ="individual " )
@@ -328,18 +328,18 @@ public function put($attributes, $type="individual")
328
328
$ this ->retreiveEndPoint ('put ' ),
329
329
$ attributes ,
330
330
$ this ->combineQueries ()
331
- ]), $ type );
331
+ ]), $ type. ' Put ' );
332
332
}
333
333
334
- public function delete ($ type ="individual " )
334
+ public function delete ($ type ="individual " )
335
335
{
336
336
if ($ this ->resource ->beforeDeleteQuery ($ this ) === false ){
337
337
return ;
338
338
}
339
339
return $ this ->handleResponse ($ this ->sendRequest ('delete ' , [
340
340
$ this ->retreiveEndPoint ('delete ' ),
341
341
$ this ->combineQueries ()
342
- ]), $ type );
342
+ ]), $ type. ' Delete ' );
343
343
}
344
344
345
345
public function first ()
@@ -364,12 +364,12 @@ public function addQuery($key, $value)
364
364
return $ this ;
365
365
}
366
366
367
- public function whereRaw ($ column , $ value )
367
+ public function whereRaw ($ column , $ value )
368
368
{
369
369
$ this ->addQuery ($ column , $ value );
370
370
return $ this ;
371
371
}
372
-
372
+
373
373
public function where ($ column , $ operand = null , $ value = null )
374
374
{
375
375
if (is_array ($ column )){
@@ -433,7 +433,7 @@ protected function addWhereContains($column, $operand, $value)
433
433
$ this ->wheres [] = ['column ' => $ column , 'operand ' => $ operand , 'value ' => $ value ];
434
434
}
435
435
436
- public function whereIn (array $ values , $ column ="" )
436
+ public function whereIn (array $ values , $ column ="" )
437
437
{
438
438
$ string = implode (', ' , $ values );
439
439
if ($ column == '' ){
@@ -443,24 +443,24 @@ public function whereIn(array $values, $column="")
443
443
return $ this ;
444
444
}
445
445
446
- public function orderBy ($ value , $ column ='order ' )
446
+ public function orderBy ($ value , $ column ='order ' )
447
447
{
448
448
$ this ->orders [$ column ] = $ value ;
449
449
return $ this ;
450
450
}
451
451
452
- public function count ()
452
+ public function count ()
453
453
{
454
454
return $ this ->get ()->count ();
455
455
}
456
456
457
- public function setPaginate ($ status =true )
457
+ public function setPaginate ($ status =true )
458
458
{
459
459
$ this ->paginate = $ status ;
460
460
return $ this ;
461
461
}
462
462
463
- public function shouldPaginate ()
463
+ public function shouldPaginate ()
464
464
{
465
465
return $ this ->paginate ;
466
466
}
@@ -519,13 +519,13 @@ public function setPage($page)
519
519
return $ this ;
520
520
}
521
521
522
- public function raw ($ status =true )
522
+ public function raw ($ status =true )
523
523
{
524
524
$ this ->raw = $ status ;
525
525
return $ this ;
526
526
}
527
527
528
- public function withExceptions ($ status =true )
528
+ public function withExceptions ($ status =true )
529
529
{
530
530
$ this ->throwExceptionsIfRaw = $ status ;
531
531
return $ this ;
@@ -536,7 +536,7 @@ public function isRaw()
536
536
return $ this ->raw ;
537
537
}
538
538
539
- protected function combineQueries ()
539
+ protected function combineQueries ()
540
540
{
541
541
return array_merge ($ this ->processQueries (), $ this ->processOrders ());
542
542
}
@@ -556,12 +556,12 @@ protected function processWheres()
556
556
return $ this ;
557
557
}
558
558
559
- public function processWhereEquals ($ detail )
559
+ public function processWhereEquals ($ detail )
560
560
{
561
561
$ this ->processedWheres [$ detail ['column ' ]] = $ detail ['value ' ];
562
562
}
563
563
564
- public function processWhereNotEquals ($ detail )
564
+ public function processWhereNotEquals ($ detail )
565
565
{
566
566
$ this ->processedWheres [$ detail ['column ' ]] = '- ' .$ detail ['value ' ];
567
567
}
@@ -601,7 +601,7 @@ protected function processOrders()
601
601
return $ this ->orders ;
602
602
}
603
603
604
- public function addPagination ($ array )
604
+ public function addPagination ($ array )
605
605
{
606
606
if ($ this ->perPage != '' ){
607
607
$ array [$ this ->perPageField ] = $ this ->perPage ;
@@ -647,7 +647,7 @@ public function resetOrders()
647
647
$ this ->orders = [];
648
648
return $ this ;
649
649
}
650
-
650
+
651
651
protected function processGetResponse ($ response )
652
652
{
653
653
return new ResultSet ($ this , $ response , $ this ->resource );
@@ -672,9 +672,121 @@ protected function processIndividualResponse($response)
672
672
}
673
673
}
674
674
675
+ protected function processIndividualPostResponse ($ response )
676
+ {
677
+ if ($ this ->getApiDataField () != null ){
678
+ $ data = $ response ->json ()[$ this ->getApiDataField ()];
679
+ } else {
680
+ $ data = $ response ->json ();
681
+ }
682
+ if (isset ($ data [0 ])){
683
+ return $ this ->resource ->updateFromBuilder ($ this ->resource ->passOnAttributes ($ data [0 ]));
684
+ } else {
685
+ return $ this ->resource ->updateFromBuilder ($ this ->resource ->passOnAttributes ($ data ));
686
+ }
687
+ }
688
+
689
+ protected function processMultiPostResponse ($ response )
690
+ {
691
+ // if($this->getApiDataField() != null){
692
+ // $data = $response->json()[$this->getApiDataField()];
693
+ // } else {
694
+ // $data = $response->json();
695
+ // }
696
+ // if(isset($data[0])){
697
+ // return $this->resource->newFromBuilder($this->resource->passOnAttributes($data[0]));
698
+ // } else {
699
+ // return $this->resource->newFromBuilder($this->resource->passOnAttributes($data));
700
+ // }
701
+ }
702
+
703
+ protected function processIndividualPatchResponse ($ response )
704
+ {
705
+ if ($ this ->getApiDataField () != null ){
706
+ $ data = $ response ->json ()[$ this ->getApiDataField ()];
707
+ } else {
708
+ $ data = $ response ->json ();
709
+ }
710
+ if (isset ($ data [0 ])){
711
+ return $ this ->resource ->updateFromBuilder ($ this ->resource ->passOnAttributes ($ data [0 ]));
712
+ } else {
713
+ return $ this ->resource ->updateFromBuilder ($ this ->resource ->passOnAttributes ($ data ));
714
+ }
715
+ }
716
+
717
+ protected function processMultiPatchResponse ($ response )
718
+ {
719
+ // if($this->getApiDataField() != null){
720
+ // $data = $response->json()[$this->getApiDataField()];
721
+ // } else {
722
+ // $data = $response->json();
723
+ // }
724
+ // if(isset($data[0])){
725
+ // return $this->resource->newFromBuilder($this->resource->passOnAttributes($data[0]));
726
+ // } else {
727
+ // return $this->resource->newFromBuilder($this->resource->passOnAttributes($data));
728
+ // }
729
+ }
730
+
731
+ protected function processIndividualPutResponse ($ response )
732
+ {
733
+ if ($ this ->getApiDataField () != null ){
734
+ $ data = $ response ->json ()[$ this ->getApiDataField ()];
735
+ } else {
736
+ $ data = $ response ->json ();
737
+ }
738
+ if (isset ($ data [0 ])){
739
+ return $ this ->resource ->updateFromBuilder ($ this ->resource ->passOnAttributes ($ data [0 ]));
740
+ } else {
741
+ return $ this ->resource ->updateFromBuilder ($ this ->resource ->passOnAttributes ($ data ));
742
+ }
743
+ }
744
+
745
+ protected function processMultiPutResponse ($ response )
746
+ {
747
+ // if($this->getApiDataField() != null){
748
+ // $data = $response->json()[$this->getApiDataField()];
749
+ // } else {
750
+ // $data = $response->json();
751
+ // }
752
+ // if(isset($data[0])){
753
+ // return $this->resource->newFromBuilder($this->resource->passOnAttributes($data[0]));
754
+ // } else {
755
+ // return $this->resource->newFromBuilder($this->resource->passOnAttributes($data));
756
+ // }
757
+ }
758
+
759
+ protected function processIndividualDeleteResponse ($ response )
760
+ {
761
+ if ($ this ->getApiDataField () != null ){
762
+ $ data = $ response ->json ()[$ this ->getApiDataField ()];
763
+ } else {
764
+ $ data = $ response ->json ();
765
+ }
766
+ if (isset ($ data [0 ])){
767
+ return $ this ->resource ->updateFromBuilder ($ this ->resource ->passOnAttributes ($ data [0 ]));
768
+ } else {
769
+ return $ this ->resource ->updateFromBuilder ($ this ->resource ->passOnAttributes ($ data ));
770
+ }
771
+ }
772
+
773
+ protected function processMultiDeleteResponse ($ response )
774
+ {
775
+ // if($this->getApiDataField() != null){
776
+ // $data = $response->json()[$this->getApiDataField()];
777
+ // } else {
778
+ // $data = $response->json();
779
+ // }
780
+ // if(isset($data[0])){
781
+ // return $this->resource->newFromBuilder($this->resource->passOnAttributes($data[0]));
782
+ // } else {
783
+ // return $this->resource->newFromBuilder($this->resource->passOnAttributes($data));
784
+ // }
785
+ }
786
+
675
787
public function prepareHttpErrorMessage ($ response )
676
788
{
677
789
return $ response ->json ()['message ' ];
678
790
}
679
791
680
- }
792
+ }
0 commit comments