Skip to content

Instantly share code, notes, and snippets.

@alanfluff
Forked from adamkiss/gist:2484276
Last active December 12, 2015 02:29
Show Gist options
  • Save alanfluff/4699345 to your computer and use it in GitHub Desktop.
Save alanfluff/4699345 to your computer and use it in GitHub Desktop.
<?php
//This just blew my mind
//
//User has field 'userPages'[Pagefield type], where administrator added parts of whole tree avail. to user.
//This checks whether current page (wrapped in object) or any of its parents was added to this 'userPages'
//(thus current page or anything higher in the hierarchy gives user the access)
//wow.
$access =
count(
Wire::getFuel('user')->userPages->find(
'id='.$this->page->parents()
->append($this->page)
)
) > 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment