Skip to content

Instantly share code, notes, and snippets.

@jxlwqq jxlwqq/apiRoute.php
Last active Mar 4, 2019

Embed
What would you like to do?
Best practice for API route
<?php
$form->select('user_id')->options(function ($id) {
$user = User::find($id);
if ($user) {
return [$user->id => $user->name];
}
})->ajax(admin_url('api/users')); # Best practice
# })->ajax('/admin/api/users'); # Strongly not recommended
@robinhoo1973

This comment has been minimized.

Copy link

commented Dec 15, 2018

admin_url() just do it as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.