Vayu Robins Posted June 26, 2015 Share Posted June 26, 2015 Hi. I need to compare two pagefields. I tried this: $page->locations->has($user->locations) But this doesn't work. I need to compare them and find out if the $page->locations has one or more of the same locations as the $user->locations. Hope it makes sense. Link to comment Share on other sites More sharing options...
Wanze Posted June 26, 2015 Share Posted June 26, 2015 PageArray::has() only accepts a single object. You need a loop, here's an example: $found = false; foreach ($user->locations as $location) { if ($page->locations->has($location) { $found = true; break; } } 3 Link to comment Share on other sites More sharing options...
Vayu Robins Posted July 1, 2015 Author Share Posted July 1, 2015 Hey Wanze. Thanks, that works great! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now