I'm working on an e-commerce website and i need to display certain data based on the user role. Basically the page can be viewed by three types of people: normal people who enters the page and by a client user or an admin who have their accounts but they see different buttons/data according to their role. I'm working with jetstream authenticaton system and what i do is simply verify the user role on my views like this:
@if (Auth::user()->role->name == 'admin')
//display button only the admin can see
@else
//display button only a client user can see
@endif
My question is, can i implement something like a gate to centralize the condition?, i mean, in case i need to change it only doing it in one file and avoid to do it in all the lines where i implented it. Any help is welcome. Thanks!