Completed
Push — master ( 1063d7...a7489f )
by Laurent
03:16
created

InventoryRepository::getLastInventory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
/**
4
 * Entité Inventory.
5
 *
6
 * PHP Version 5
7
 *
8
 * @author    Quétier Laurent <[email protected]>
9
 * @copyright 2014 Dev-Int GLSR
10
 * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
11
 *
12
 * @version GIT: <git_id>
13
 *
14
 * @link https://github.com/Dev-Int/glsr
15
 */
16
namespace AppBundle\Repository\Stocks;
17
18
use Doctrine\ORM\EntityRepository;
19
20
/**
21
 * InventoryRepository
22
 *
23
 * @category Entity
24
 */
25
class InventoryRepository extends EntityRepository
26
{
27
    /**
28
     * Affiche tous les inventaires.
29
     *
30
     * @return QueryBuilder Requête DQL
31
     */
32
    public function getAllItems()
33
    {
34
        $query = $this->createQueryBuilder('i')
35
            ->orderBy('i.id', 'DESC');
36
        
37
        return $query;
38
    }
39
40
    /**
41
     * Affiche les inventaires actifs.
42
     *
43
     * @return QueryBuilder Requête DQL
44
     */
45
    public function getItems()
46
    {
47
        $query = $this->getAllItems()
48
            ->where('i.status > 0');
49
50
        return $query;
51
    }
52
53
    /**
54
     * Renvoi les derniers inventaires.
55
     *
56
     * @param integer $count Nombre d'élément à afficher
57
     * @return array Query result
58
     */
59
    public function getLastInventory($count)
60
    {
61
        $query = $this->getItems()
62
            ->setMaxResults($count)
63
            ->getQuery();
64
65
        return $query->getResult();
66
    }
67
}
68