Livewire might be the answer: https://laravel-livewire.com/
May 5, 2020
2
Level 1
Hide create button without refresh on page
Hi All,
New to Laravel and Nova!
I am running into an issue and looked online and didn't get any luck. What I am attempting to do is hide the "Create button" for Nova via a policy. I check to see the number of records in the database with the organization id. If there is two I need to hide the create button else the user can see the button. Currently the solution works, but requires a refresh to the page to see the button hidden or unhidden if a record is deleted. Is it possible to hide or show the create button without a refresh to the page?
/*
Checks if the User is the Organization Admin or
if the the User is Standard
*/
if ($user->isOrgAdmin() || $user->isStandard() || $user->isSystemAdmin()) {
//Get submission from database
$submission = Submission::where('organization_id', $user->organization_id)->get();
//Check to see if there are two forms already created
if (count($submission) == 2) {
//Dont allow another form to be created
return false;
} else {
//Form can be created
return true;
}
}
Thanks!
Please or to participate in this conversation.