Last active
March 4, 2019 11:07
-
-
Save jxlwqq/65897e4120ecbc5d7b0e5aaf6f89b2fc to your computer and use it in GitHub Desktop.
Best practice for API route
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
admin_url() just do it as expected