/
var
/
www
/
html
/
restaurants
/
src
/
Repository
/
Upload File
HOME
<?php namespace App\Repository; /** * StockRepository * * This class was generated by the Doctrine ORM. Add your own custom * repository methods below. */ class StockRepository extends \Doctrine\ORM\EntityRepository { public function findStock($user) { return $this->getEntityManager() ->createQuery( 'SELECT s.id as id, i.name as name, i.id as item_id, s.quantity FROM App\Entity\Stock s, App\Entity\Item i WHERE s.itemId = i.id AND s.userId = :user ORDER BY i.name ASC' )->setParameter('user', $user) ->getResult(); } public function findByItem($id, $user) { return $this->getEntityManager() ->createQuery( 'SELECT s FROM App\Entity\Stock s WHERE s.itemId = :id AND s.userId = :user' )->setParameter('id', $id) ->setParameter('user', $user) ->getResult(); } public function findStockSales() { return $this->getEntityManager() ->createQuery( 'SELECT s.name, oi.quantity, oi.price, o.date FROM App\Entity\Stock s, App\Entity\Item i, App\Entity\Orders o, App\Entity\OrderItem oi, App\Entity\ItemPart ip ' )->getResult(); } }