You are here

public function LibraryItem::getLatestTransactionDue in Library 8

Get the latest transaction which is due.

Return value

array Latest transaction.

File

src/Entity/LibraryItem.php, line 197

Class

LibraryItem
Defines the Library item entity.

Namespace

Drupal\library\Entity

Code

public function getLatestTransactionDue() {
  $transaction = \Drupal::entityQuery('library_transaction')
    ->condition('library_item', $this
    ->id())
    ->condition('due_date', time(), '<')
    ->condition('due_date', 0, '>')
    ->sort('id', 'DESC')
    ->range(0, 1)
    ->execute();
  return $transaction;
}