Skip to content

Instantly share code, notes, and snippets.

@Adamwaheed
Last active August 29, 2015 14:15
Show Gist options
  • Save Adamwaheed/ca1fafc1324442e6451a to your computer and use it in GitHub Desktop.
Save Adamwaheed/ca1fafc1324442e6451a to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Middleware;
use Closure;
use App\user;
use App\GroupRresources;
use App\Resources;
class PermissionChecker {
public function handle($request, Closure $next)
{
$user = User::with('group')
->where('id',1)
->first();
$resources = Resources::where('action_name','=',$request->path())->first();
$isAth = GroupRresources::where('user_group_id','=', $user->user_group_id)
->where('resources_id','=',$resources->id)->first();
if (!$isAth)
{
//return response('Unauthorized.', 401);
}
return $next($request);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment