mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
filter list of locations on backend side (GET location endpoint)
This commit is contained in:
parent
d0dd99db9a
commit
ada9efc75d
@ -62,7 +62,7 @@ export default {
|
|||||||
getLocationsList() {
|
getLocationsList() {
|
||||||
getLocations().then(response => new Promise(resolve => {
|
getLocations().then(response => new Promise(resolve => {
|
||||||
console.log('getLocations', response);
|
console.log('getLocations', response);
|
||||||
this.locations = response.results.filter(l => l.availableForUsers === true);
|
this.locations = response.results;
|
||||||
resolve();
|
resolve();
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\MainBundle\Controller;
|
||||||
|
|
||||||
|
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class LocationApiController
|
||||||
|
*
|
||||||
|
* @package Chill\MainBundle\Controller
|
||||||
|
* @author Champs Libres
|
||||||
|
*/
|
||||||
|
class LocationApiController extends ApiController
|
||||||
|
{
|
||||||
|
public function customizeQuery(string $action, Request $request, $query): void
|
||||||
|
{
|
||||||
|
$query->andWhere($query->expr()->orX(
|
||||||
|
$query->expr()->andX(
|
||||||
|
$query->expr()->eq('e.createdBy', ':user'),
|
||||||
|
$query->expr()->eq('e.createdAt', ':dateBefore')
|
||||||
|
),
|
||||||
|
$query->expr()->eq('e.availableForUsers', "'TRUE'")
|
||||||
|
))
|
||||||
|
->setParameters([
|
||||||
|
'user' => $this->getUser(),
|
||||||
|
'dateBefore' => (new \DateTime())->sub(new \DateInterval('P6M'))
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -447,6 +447,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
'class' => \Chill\MainBundle\Entity\Location::class,
|
'class' => \Chill\MainBundle\Entity\Location::class,
|
||||||
|
'controller' => \Chill\MainBundle\Controller\LocationApiController::class,
|
||||||
'name' => 'location',
|
'name' => 'location',
|
||||||
'base_path' => '/api/1.0/main/location',
|
'base_path' => '/api/1.0/main/location',
|
||||||
'base_role' => 'ROLE_USER',
|
'base_role' => 'ROLE_USER',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user