Bristol SU Support Package
CheckActivityFor.php
Go to the documentation of this file.
1 <?php
2 
4 
8 use Closure;
10 
15 {
21  private $authentication;
22 
29  {
30  $this->authentication = $authentication;
31  }
32 
41  public function handle(Request $request, Closure $next)
42  {
43  $activity = $request->route('activity_slug');
44  $logic = $activity->forLogic;
45  if (!LogicTester::evaluate($logic, $this->authentication->getUser(), $this->authentication->getGroup(), $this->authentication->getRole())) {
46  throw ActivityRequiresParticipant::createWithActivity($activity, 'You do not have access to this activity,', 403);
47  }
48  return $next($request);
49  }
50 }
static createWithActivity(Activity $activity, string $message='', int $code=0)