Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attach will not trigger forgetCachedPermissions() #5

Closed
jianminLee opened this issue Dec 18, 2018 · 2 comments
Closed

Attach will not trigger forgetCachedPermissions() #5

jianminLee opened this issue Dec 18, 2018 · 2 comments

Comments

@jianminLee
Copy link

class ForgetCachedPermissions
{
	/**
	 * Handle the incoming request.
	 *
	 * @param \Illuminate\Http\Request $request
	 * @param \Closure                 $next
	 *
	 * @return \Illuminate\Http\Response
	 */
	public function handle($request, $next)
	{
		$response = $next($request);

		if ($request->is('nova-api/*/detach') ||
			$request->is('nova-api/*/*/attach/*')) {
			##This is my attach url: http://127.0.0.1:8000/nova-api/admins/1/attach-morphed/permissions
			$permissionKey = (Nova::resourceForModel(app(PermissionRegistrar::class)->getPermissionClass()))::uriKey();

			if ($request->viaRelationship === $permissionKey) {
				app(PermissionRegistrar::class)->forgetCachedPermissions();
			}
		}

		return $response;
	}
}
@paras-malhotra
Copy link
Contributor

Thanks for reporting @jianminLee. Can you make a PR for this? I think $request->is('nova-api/*/*/attach*') may work.

@jianminLee
Copy link
Author

@paras-malhotra try:

$request->is('nova-api/*/*/attach*/*')

is work.

jianminLee pushed a commit to jianminLee/laravel-nova-permission that referenced this issue Dec 18, 2018
funkdoobiest added a commit to funkdoobiest/laravel-nova-permission that referenced this issue Oct 11, 2019
fix issues insenseanalytics#5 and permission title not translate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants