You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					35 lines
				
				1008 B
			
		
		
			
		
	
	
					35 lines
				
				1008 B
			| 
								 
											2 years ago
										 
									 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								namespace App\Http\Controllers\Api\V1;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								use App\CentralLogics\Helpers;
							 | 
						||
| 
								 | 
							
								use App\Http\Controllers\Controller;
							 | 
						||
| 
								 | 
							
								use App\Models\WalletTransaction;
							 | 
						||
| 
								 | 
							
								use Illuminate\Support\Facades\Validator;
							 | 
						||
| 
								 | 
							
								use Illuminate\Http\Request;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								class WalletController extends Controller
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    public function transactions(Request $request)
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        $validator = Validator::make($request->all(), [
							 | 
						||
| 
								 | 
							
								            'limit' => 'required',
							 | 
						||
| 
								 | 
							
								            'offset' => 'required',
							 | 
						||
| 
								 | 
							
								        ]);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        if ($validator->fails()) {
							 | 
						||
| 
								 | 
							
								            return response()->json(['errors' => Helpers::error_processor($validator)], 403);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        $paginator = WalletTransaction::where('user_id', $request->user()->id)->latest()->paginate($request->limit, ['*'], 'page', $request->offset);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        $data = [
							 | 
						||
| 
								 | 
							
								            'total_size' => $paginator->total(),
							 | 
						||
| 
								 | 
							
								            'limit' => $request->limit,
							 | 
						||
| 
								 | 
							
								            'offset' => $request->offset,
							 | 
						||
| 
								 | 
							
								            'data' => $paginator->items()
							 | 
						||
| 
								 | 
							
								        ];
							 | 
						||
| 
								 | 
							
								        return response()->json($data, 200);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 |