Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.

Commit 0128a6e

Browse files
committed
Helper: Added role() and permission()
1 parent 9e27e6d commit 0128a6e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

app/Support/helpers.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use Illuminate\Support\Facades\Cache;
4+
35
/*
46
* generate sequence
57
* @return sequence based on length supplied
@@ -184,3 +186,27 @@ function locales()
184186
});
185187
}
186188
}
189+
190+
/*
191+
* Get Role by Name
192+
*/
193+
if (! function_exists('role')) {
194+
function role($name)
195+
{
196+
return Cache::remember('role_' . $name, 10, function () use ($name) {
197+
return config('permission.models.role')::findByName($name);
198+
});
199+
}
200+
}
201+
202+
/*
203+
* Get Permission by Name
204+
*/
205+
if (! function_exists('permission')) {
206+
function permission($name)
207+
{
208+
return Cache::remember('permission_' . $name, 10, function () use ($name) {
209+
return config('permission.models.permission')::findByName($name);
210+
});
211+
}
212+
}

0 commit comments

Comments
 (0)