SR
$ar = $collection->toArray();
$found_key = array_search($id, array_column($ar, 'id'));
$next_product = $collection->get($found_key+1);
$prev_product = $collection->get($found_key-1);
return array($prev_product, $next_product);
}
Size: a a a
SR
v
public function neighbors($collection, $id): ?Collection
{
$itemIndex = $collection->search(static function ($item, $key) use($id): bool {
return $item->getKey() === $id;
});
return $collection->only([$itemIndex + 1, $itemIndex - 1]);
}
AP
A
AP
КА
A
AY
КА
КА
Event::listen('backend.page.beforeDisplay', function($controller, $action, $params) {
$controller->addJs('/path/to/your/javascript/file.js');
});
КА
D
Event::listen('backend.page.beforeDisplay', function($controller, $action, $params) {
$controller->addJs('/path/to/your/javascript/file.js');
});
КА
КА
A
AY
A
AY
A
jd