Skip to content

Instantly share code, notes, and snippets.

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

What would you like to do?
Best practice for API route
$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

This comment has been minimized.

Copy link

robinhoo1973 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.