PHP code example of kalimulhaq / json-query
1. Go to this page and download the library: Download kalimulhaq/json-query library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kalimulhaq / json-query example snippets
php
use Illuminate\Http\Request;
use Kalimulhaq\JsonQuery\JsonQueryFacade as JsonQuery;
class UsersController extends Controller {
public function index(Request $request) {
$this->user = $request->user();
$json2query = JsonQuery::init('App\User', $request->filter);
$json2query->buildQuery();
$json2query->buildResult($request->limit, $request->page);
$result = $json2query->result();
$meta = $json2query->meta();
return response()->json(['data' => $result, 'paginator' => $meta]);
}
}