FoxSecrets
Active member
I'm getting error "undefined method array_map" in my function.
Should I import some class in order to work? Or any special xf tag to loop in query results?
PHP
Should I import some class in order to work? Or any special xf tag to loop in query results?
PHP
Code:
public function actionExpire()
{
$books = $this->finder('FOX\Books:Book')->where('status', 'valid')->fetch();
$books->array_map(
function($book) {
if ($book->expiration < time())
{
$book->status = 'expired';
$book->save();
}
}
);
return $this->redirect($this->buildLink('fox-books'));
}