PHP code example of hellomohsinhello / laravel-relation-parser
1. Go to this page and download the library: Download hellomohsinhello/laravel-relation-parser 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/ */
hellomohsinhello / laravel-relation-parser example snippets
use SalamWaddah\RelationParser\LoadsRelations;
use Illuminate\Http\Request;
class UsersController extends Controller
{
use LoadsRelations;
public function index(Request $request)
{
$users = User::query()
// .. your query logic here
->get();
// this line adds the relations/counts
$this->loadRelations($users, $request);
// return your results however you like
return response()->json($users);
}
}