laravel-eloquent-resource

Adding filter to eloquent resource to attach relationship conditionally

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 04:58:54
问题 Laravel 5.8 PHP 7.4 I want to load the relationships conditionally like http://127.0.0.1:8000/api/posts and http://127.0.0.1:8000/api/posts/1 are my end points now, I want to load comments like http://127.0.0.1:8000/api/posts/?include=comments and http://127.0.0.1:8000/api/posts/1/?include=comments If the query parameter is there, only then it should load comments with posts or it should load only posts/post I am doing this by referring a blog post now, RequestQueryFilter <?php namespace App