PHP code example of matteomeloni / laravel-rest-ql
1. Go to this page and download the library: Download matteomeloni/laravel-rest-ql 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/ */
matteomeloni / laravel-rest-ql example snippets
namespace App\Models;
use Matteomeloni\LaravelRestQl\LaravelRestQl;
class Book extends LaravelRestQl
{
//
}
namespace App\Http\Controllers;
use App\Models\Book;
class BookController extends Controller
{
public function index()
{
$books = Book::restQL()
->get();
return response()->json($books);
}
}
namespace App\Http\Controllers;
use App\Models\Book;
class BookController extends Controller
{
public function index()
{
$data = [
'search' => ''
'columns' => [],
'filters' => [],
'sorts' => []
];
$books = Book::restQL($data)->get();
return response()->json($books);
}
}
//Route: /api/books?select=[]&filters=[]&sorts=[]&search=''
namespace App\Http\Controllers;
use App\Models\Book;
class BookController extends Controller
{
public function index()
{
$books = Book::restQL()->get();
return response()->json($books);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.