@ddsameera Sounds like what you might want to do is create a cache helper service class.
Create a folder/file in app\Services\CacheHelper.php
<?php
namespace App\Services;
use Cache;
class CacheService
{
public static function getPermissions()
{
return Cache::remember('permissions', config('cache.expire_time.short'), function () {
return Permissions::orderBy('name', 'ASC')->get();
});
}
public static function getRoles()
{
return Cache::remember("roles", config('cache.expire_time.short'), function () {
return Role::all();
});
}
}
Now, since you are using static functions here you can simply call CacheService::getPermissions() and CacheService::getRoles()after importing the service with use App\Services\CacheHelper at the top of any other class.