Hi,
Just installed the plugin, its not clear how to only allow a user to manipulate their own data. Also I was wondering if there was a way to implement custom code to the API endpoints by overwriting the functionality of the 4 provided methods post,get etc...
Thanks
Hi, Thanks for your question/heads up. The plugin provides a feature to allow user's to only update their own data. You configure this on the controller's page > behavoir tab. Select requires permissions and configure your settings according to your needs. See picture below:
With regard to customizing code for the endpoints, you have two options:
- Override the desired method in the controller.
Example:
public function update(Request $request) { // Your custom code }
- Create a trait that implements the desired methods and include it in your controller
trait CustomAPIController { public function store(Request $request) { // Your custom code } }
Then include the trait in you controller class
class VoteController extends Controller { use \Author\Plugin\CustomAPIController; }
Hi again,
Thanks for the reply.
Update worked.
Tried with index() for posts but didn't work, got the following error:
Symfony\Component\Debug\Exception\FatalThrowableError: Argument 2 passed to Symfony\Component\HttpFoundation\JsonResponse::__construct() must be of the type integer, string given
public function index(Request $request){
Log::info("In post");
}
Also it would be good to have a popup when saving the Controller, informing that any custom code written will be overwritten. Or even better if it wasn't overwritten :D
1-3 of 3