E
E
Eugene2020-10-19 18:03:58
css
Eugene, 2020-10-19 18:03:58

How to compactly write gates in Laravel?

I use gates to check permissions. If you define each resolution in this way, you get a big function. How to avoid it?

public function boot()
    {
        $this->registerPolicies();

        Gate::define('users_info', function ($admin) {
            if (! $admin->hasPermission('users_info') ) {
                throw new AccessDenyException(ErrorMessages::ACCESS_DENIED, Response::HTTP_FORBIDDEN);
            };

            return true;
        });
    }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Egor Chebotarev, 2016-03-23
@Egche

You can use js
. You have 4 columns, each of which looks like this:

<div class="overflow" style="overflow:hidden; height:800px;">
  
  <div class="scroll" style="height:100%;">
    
    <div class="item"></div>
    
  </div>
  
</div>

.overflow - div in which the carousel scrolls
.scroll - div in which the photo is contained. Has a height equal to the sum of the height of the photo and the padding. It is advisable to calculate as .item.clientHeight, going through all the photos using for and not forgetting to add indents.
.scroll can be set to position:absolute and change top via js and moving items that have left the screen to the end via replaceChild
Implementation of similar functionality
https://learn.javascript.ru/task/carousel

S
Sanes, 2020-10-20
@Sanes

There are also ready-made packages. Why this suffering?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question