Ok, first one: $this->value()
is just a string, so you would have to make that into an array: explode(',', $this->value()
. And then compare the two arrays.
As regards also, try site()->index()
.
As regards also also, panel()->notify()
should do the job.
public function validate() {
$pages = site()->index()->not($this->page());
$values = $pages->pluck('intro', ',', true);
$currentValues = explode(',', $this->value);
if(empty(array_intersect($currentValues, $values))) {
return true;
} else {
panel()->alert('Oh no, how dare you!');
panel()->redirect('pages/' . $this->page() . '/edit');
return false;
}
}