some progress
This commit is contained in:
parent
49bd0cad39
commit
af9fe70ec6
|
@ -1,10 +1,14 @@
|
|||
nelmio_cors:
|
||||
defaults:
|
||||
origin_regex: true
|
||||
allow_origin: ['%env(CORS_ALLOW_ORIGIN)%']
|
||||
allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
|
||||
allow_headers: ['Content-Type', 'Authorization']
|
||||
allow_origin: ['*']
|
||||
allow_methods: ['*']
|
||||
allow_headers: ['*']
|
||||
expose_headers: ['Link']
|
||||
max_age: 3600
|
||||
paths:
|
||||
'^/': null
|
||||
'^/api/':
|
||||
allow_origin: [ '*' ]
|
||||
allow_headers: [ '*' ]
|
||||
allow_methods: [ 'POST', 'PUT', 'GET', 'DELETE' ]
|
||||
max_age: 3600
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
use App\Kernel;
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
|
||||
|
||||
return function (array $context) {
|
||||
|
|
|
@ -3,20 +3,127 @@
|
|||
namespace App\Controller;
|
||||
|
||||
use App\Entity\BlogCat;
|
||||
use App\Entity\BlogPost;
|
||||
use App\Entity\StackCat;
|
||||
use App\Entity\StackContent;
|
||||
use App\Service\Jdate;
|
||||
use App\Service\Provider;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
|
||||
class BlogController extends AbstractController
|
||||
{
|
||||
#[Route('/api/blog/get_cats', name: 'app_blog_get_cats')]
|
||||
#[Route('/api/blog/cats/get', name: 'app_blog_get_cats')]
|
||||
public function app_blog_get_cats(SerializerInterface $serializer, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$result = [];
|
||||
$cats = $entityManager->getRepository(BlogCat::class)->findAll();
|
||||
foreach ($cats as $cat){
|
||||
$temp = [];
|
||||
$temp['id'] = $cat->getId();
|
||||
$temp['name'] = $cat->getLabel();
|
||||
$temp['code'] = $cat->getCode();
|
||||
$result[] = $temp;
|
||||
}
|
||||
return $this->json($result);
|
||||
}
|
||||
|
||||
#[Route('/api/blog/insert', name: 'app_blog_content_insert')]
|
||||
public function app_blog_content_insert(Request $request,SerializerInterface $serializer, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
$params = json_decode($content, true);
|
||||
}
|
||||
if(array_key_exists('intro',$params) && array_key_exists('title',$params) && array_key_exists('cat',$params) && array_key_exists('body',$params )){
|
||||
$cat = $entityManager->getRepository(BlogCat::class)->find($params['cat']);
|
||||
$post = new BlogPost();
|
||||
$post->setBody($params['body']);
|
||||
$post->setCat($cat);
|
||||
$post->setIntero($params['intro']);
|
||||
$post->setImg($params['img']);
|
||||
$post->setTitle($params['title']);
|
||||
$post->setDateSubmit(time());
|
||||
$post->setViews(1);
|
||||
$post->setSubmitter($this->getUser());
|
||||
$post->setUrl(str_replace(' ','_',$params['title']));
|
||||
$entityManager->persist($post);
|
||||
$entityManager->flush();
|
||||
return $this->json([
|
||||
'error'=> 0,
|
||||
'message'=> 'ok',
|
||||
'url'=>$post->getUrl()
|
||||
]);
|
||||
}
|
||||
return $this->json([
|
||||
'error' => 0,
|
||||
'data' => $serializer->serialize($entityManager->getRepository(BlogCat::class)->findAll(),'json'),
|
||||
'error'=> 999,
|
||||
'message'=> 'تمام موارد لازم را وارد کنید.'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
||||
* @throws \Doctrine\ORM\NoResultException
|
||||
*/
|
||||
#[Route('/api/blog/contents/search', name: 'app_blog_contents_get')]
|
||||
public function app_blog_contents_get(Jdate $jdate, Provider $provider,Request $request,SerializerInterface $serializer, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
$params = json_decode($content, true);
|
||||
}
|
||||
$params = $provider->createSearchParams($request);
|
||||
$items = $entityManager->getRepository(BlogPost::class)->search($params);
|
||||
$response = [];
|
||||
foreach ($items as $item){
|
||||
$temp = [];
|
||||
$temp['id'] = $item->getId();
|
||||
$temp['title'] = $item->getTitle();
|
||||
$temp['intero'] = $item->getIntero();
|
||||
$temp['body'] = $item->getBody();
|
||||
$temp['submitter'] = $item->getSubmitter()->getFullName();
|
||||
$temp['dateSubmit'] = $jdate->pastTime($item->getDateSubmit());
|
||||
$temp['cat'] = $item->getCat()->getLabel();
|
||||
$temp['views'] = $item->getViews();
|
||||
$temp['url'] = $item->getUrl();
|
||||
$temp['img'] = $item->getImg();
|
||||
$response[] = $temp;
|
||||
}
|
||||
// calc has next page
|
||||
$nextPage = true;
|
||||
if((int)$provider->maxPages($params,$entityManager->getRepository(BlogPost::class)->getAllContentCount()) == $params['page'])
|
||||
$nextPage = false;
|
||||
return $this->json([
|
||||
'data'=>$response,
|
||||
'nextPage'=>$nextPage
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
||||
* @throws \Doctrine\ORM\NoResultException
|
||||
*/
|
||||
#[Route('/api/blog/post/get/{url}', name: 'app_blog_post_get')]
|
||||
public function app_blog_post_get($url,Jdate $jdate, Provider $provider,Request $request,SerializerInterface $serializer, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$post = $entityManager->getRepository(BlogPost::class)->findOneBy(['url'=>$url]);
|
||||
if(!$post)
|
||||
throw $this->createNotFoundException();
|
||||
$temp = [];
|
||||
$temp['id'] = $post->getId();
|
||||
$temp['title'] = $post->getTitle();
|
||||
$temp['intero'] = $post->getIntero();
|
||||
$temp['body'] = $post->getBody();
|
||||
$temp['submitter'] = $post->getSubmitter()->getFullName();
|
||||
$temp['dateSubmit'] = $jdate->pastTime($post->getDateSubmit());
|
||||
$temp['cat'] = $post->getCat()->getLabel();
|
||||
$temp['views'] = $post->getViews();
|
||||
$temp['url'] = $post->getUrl();
|
||||
$temp['img'] = $post->getImg();
|
||||
return $this->json($temp);
|
||||
}
|
||||
}
|
||||
|
|
42
src/Controller/BusinessController.php
Normal file
42
src/Controller/BusinessController.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Entity\Business;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
|
||||
use Symfony\Component\Security\Http\Attribute\CurrentUser;
|
||||
|
||||
class BusinessController extends AbstractController
|
||||
{
|
||||
#[Route('/api/business/list', name: 'api_bussiness_list')]
|
||||
public function api_login(#[CurrentUser] ?User $user,EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$buss = $entityManager->getRepository(Business::class)->findBy(['owner'=>$user]);
|
||||
$response = [];
|
||||
foreach ($buss as $bus){
|
||||
$temp = [];
|
||||
$temp['id'] = $bus->getId();
|
||||
$temp['name'] = $bus->getName();
|
||||
$temp['owner'] = $bus->getOwner()->getFullName();
|
||||
$temp['legal_name'] = $bus->getLegalName();
|
||||
$response[] = $temp;
|
||||
}
|
||||
|
||||
return $this->json($response);
|
||||
}
|
||||
|
||||
#[Route('/api/business/list/count', name: 'api_bussiness_list_count')]
|
||||
public function api_bussiness_list_count(#[CurrentUser] ?User $user,EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$buss = $entityManager->getRepository(Business::class)->findBy(['owner'=>$user]);
|
||||
$response = ['count'=>count($buss)];
|
||||
return $this->json($response);
|
||||
}
|
||||
}
|
|
@ -3,6 +3,8 @@
|
|||
namespace App\Entity;
|
||||
|
||||
use App\Repository\BlogCatRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: BlogCatRepository::class)]
|
||||
|
@ -19,6 +21,14 @@ class BlogCat
|
|||
#[ORM\Column(length: 255)]
|
||||
private ?string $code = null;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'cat', targetEntity: BlogPost::class, orphanRemoval: true)]
|
||||
private Collection $blogPosts;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->blogPosts = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
|
@ -47,4 +57,34 @@ class BlogCat
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, BlogPost>
|
||||
*/
|
||||
public function getBlogPosts(): Collection
|
||||
{
|
||||
return $this->blogPosts;
|
||||
}
|
||||
|
||||
public function addBlogPost(BlogPost $blogPost): self
|
||||
{
|
||||
if (!$this->blogPosts->contains($blogPost)) {
|
||||
$this->blogPosts->add($blogPost);
|
||||
$blogPost->setCat($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeBlogPost(BlogPost $blogPost): self
|
||||
{
|
||||
if ($this->blogPosts->removeElement($blogPost)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($blogPost->getCat() === $this) {
|
||||
$blogPost->setCat(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
158
src/Entity/BlogPost.php
Normal file
158
src/Entity/BlogPost.php
Normal file
|
@ -0,0 +1,158 @@
|
|||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\BlogPostRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: BlogPostRepository::class)]
|
||||
class BlogPost
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $title = null;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT)]
|
||||
private ?string $body = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'blogPosts')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?User $submitter = null;
|
||||
|
||||
#[ORM\Column(length: 50)]
|
||||
private ?string $dateSubmit = null;
|
||||
|
||||
#[ORM\Column(type: Types::BIGINT)]
|
||||
private ?string $views = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $img = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'blogPosts')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?BlogCat $cat = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $url = null;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT)]
|
||||
private ?string $intero = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getTitle(): ?string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle(string $title): self
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBody(): ?string
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
public function setBody(string $body): self
|
||||
{
|
||||
$this->body = $body;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSubmitter(): ?User
|
||||
{
|
||||
return $this->submitter;
|
||||
}
|
||||
|
||||
public function setSubmitter(?User $submitter): self
|
||||
{
|
||||
$this->submitter = $submitter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateSubmit(): ?string
|
||||
{
|
||||
return $this->dateSubmit;
|
||||
}
|
||||
|
||||
public function setDateSubmit(string $dateSubmit): self
|
||||
{
|
||||
$this->dateSubmit = $dateSubmit;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getViews(): ?string
|
||||
{
|
||||
return $this->views;
|
||||
}
|
||||
|
||||
public function setViews(string $views): self
|
||||
{
|
||||
$this->views = $views;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getImg(): ?string
|
||||
{
|
||||
return $this->img;
|
||||
}
|
||||
|
||||
public function setImg(?string $img): self
|
||||
{
|
||||
$this->img = $img;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCat(): ?BlogCat
|
||||
{
|
||||
return $this->cat;
|
||||
}
|
||||
|
||||
public function setCat(?BlogCat $cat): self
|
||||
{
|
||||
$this->cat = $cat;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUrl(): ?string
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
public function setUrl(string $url): self
|
||||
{
|
||||
$this->url = $url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIntero(): ?string
|
||||
{
|
||||
return $this->intero;
|
||||
}
|
||||
|
||||
public function setIntero(string $intero): self
|
||||
{
|
||||
$this->intero = $intero;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
|
@ -17,6 +17,12 @@ class Business
|
|||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?User $owner = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $name = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $legalName = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
|
@ -33,4 +39,28 @@ class Business
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLegalName(): ?string
|
||||
{
|
||||
return $this->legalName;
|
||||
}
|
||||
|
||||
public function setLegalName(string $legalName): self
|
||||
{
|
||||
$this->legalName = $legalName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,12 +47,16 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|||
#[ORM\OneToMany(mappedBy: 'submitter', targetEntity: StackContent::class, orphanRemoval: true)]
|
||||
private Collection $stackContents;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'submitter', targetEntity: BlogPost::class, orphanRemoval: true)]
|
||||
private Collection $blogPosts;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->userTokens = new ArrayCollection();
|
||||
$this->businesses = new ArrayCollection();
|
||||
$this->guideContents = new ArrayCollection();
|
||||
$this->stackContents = new ArrayCollection();
|
||||
$this->blogPosts = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
|
@ -268,4 +272,34 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, BlogPost>
|
||||
*/
|
||||
public function getBlogPosts(): Collection
|
||||
{
|
||||
return $this->blogPosts;
|
||||
}
|
||||
|
||||
public function addBlogPost(BlogPost $blogPost): self
|
||||
{
|
||||
if (!$this->blogPosts->contains($blogPost)) {
|
||||
$this->blogPosts->add($blogPost);
|
||||
$blogPost->setSubmitter($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeBlogPost(BlogPost $blogPost): self
|
||||
{
|
||||
if ($this->blogPosts->removeElement($blogPost)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($blogPost->getSubmitter() === $this) {
|
||||
$blogPost->setSubmitter(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,4 +8,14 @@ use Symfony\Component\HttpKernel\Kernel as BaseKernel;
|
|||
class Kernel extends BaseKernel
|
||||
{
|
||||
use MicroKernelTrait;
|
||||
|
||||
public function getCacheDir(): string
|
||||
{
|
||||
return str_replace('core','',dirname(__DIR__)).'cache/'.$this->environment.'/cache';
|
||||
}
|
||||
|
||||
public function getLogDir(): string
|
||||
{
|
||||
return str_replace('core','',dirname(__DIR__)).'logs/'.$this->environment.'/log';
|
||||
}
|
||||
}
|
||||
|
|
88
src/Repository/BlogPostRepository.php
Normal file
88
src/Repository/BlogPostRepository.php
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\BlogPost;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<BlogPost>
|
||||
*
|
||||
* @method BlogPost|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method BlogPost|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method BlogPost[] findAll()
|
||||
* @method BlogPost[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class BlogPostRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, BlogPost::class);
|
||||
}
|
||||
|
||||
public function save(BlogPost $entity, bool $flush = false): void
|
||||
{
|
||||
$this->getEntityManager()->persist($entity);
|
||||
|
||||
if ($flush) {
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
}
|
||||
|
||||
public function remove(BlogPost $entity, bool $flush = false): void
|
||||
{
|
||||
$this->getEntityManager()->remove($entity);
|
||||
|
||||
if ($flush) {
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @return StackContent[]
|
||||
*/
|
||||
public function search($params): array
|
||||
{
|
||||
$result = $this->createQueryBuilder('s')
|
||||
->setMaxResults($params['count'])
|
||||
->setFirstResult(($params['page'] -1) * $params['count']);
|
||||
$result->orderBy('s.id', 'DESC');
|
||||
return $result->getQuery()->getResult();
|
||||
}
|
||||
/**
|
||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
||||
* @throws \Doctrine\ORM\NoResultException
|
||||
*/
|
||||
public function getAllContentCount(): int{
|
||||
return $this->createQueryBuilder('s')
|
||||
->select('count(s.id)')
|
||||
->getQuery()
|
||||
->getSingleScalarResult()
|
||||
;
|
||||
}
|
||||
// /**
|
||||
// * @return BlogPost[] Returns an array of BlogPost objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('b')
|
||||
// ->andWhere('b.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('b.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?BlogPost
|
||||
// {
|
||||
// return $this->createQueryBuilder('b')
|
||||
// ->andWhere('b.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
|
@ -44,16 +44,20 @@ class StackContentRepository extends ServiceEntityRepository
|
|||
*/
|
||||
public function search($params): array
|
||||
{
|
||||
return $this->createQueryBuilder('s')
|
||||
$result = $this->createQueryBuilder('s')
|
||||
->setMaxResults($params['count'])
|
||||
->setFirstResult(($params['page'] -1) * $params['count'])
|
||||
->orWhere('s.body LIKE :key')
|
||||
->andWhere('s.upper is NULL')
|
||||
->orderBy('s.id', 'DESC')
|
||||
->setParameter('key','%' . $params['key'] . '%')
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
->andWhere('s.upper is NULL');
|
||||
if (array_key_exists('cat',$params)){
|
||||
if($params['cat'] != 'non')
|
||||
$result->andWhere('s.cat = :cat')
|
||||
->setParameter('cat',$params['cat']);
|
||||
}
|
||||
$result->orderBy('s.id', 'DESC')
|
||||
->setParameter('key','%' . $params['key'] . '%');
|
||||
|
||||
return $result->getQuery()->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue