Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
symfony_2504
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lech Sawoń
symfony_2504
Commits
fb19fb6b
Commit
fb19fb6b
authored
Oct 27, 2021
by
Lech Sawon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sorting form for room
parent
fa8b058a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
4 deletions
+35
-4
CategoryController.php
src/Controller/CategoryController.php
+0
-1
RoomController.php
src/Controller/RoomController.php
+5
-2
RoomRepository.php
src/Repository/RoomRepository.php
+20
-0
index.html.twig
templates/room/index.html.twig
+10
-1
No files found.
src/Controller/CategoryController.php
View file @
fb19fb6b
...
@@ -33,7 +33,6 @@ final class CategoryController extends AbstractController
...
@@ -33,7 +33,6 @@ final class CategoryController extends AbstractController
/**
/**
* @Route("/new", name="category_new", methods={"GET", "POST"})
* @Route("/new", name="category_new", methods={"GET", "POST"})
* @IsGranted("ROLE_ADMIN")
*/
*/
public
function
new
(
Request
$request
)
:
Response
public
function
new
(
Request
$request
)
:
Response
{
{
...
...
src/Controller/RoomController.php
View file @
fb19fb6b
...
@@ -18,10 +18,13 @@ class RoomController extends AbstractController
...
@@ -18,10 +18,13 @@ class RoomController extends AbstractController
/**
/**
* @Route("/", name="room_index", methods={"GET"})
* @Route("/", name="room_index", methods={"GET"})
*/
*/
public
function
index
(
RoomRepository
$roomRepository
)
:
Response
public
function
index
(
R
equest
$request
,
R
oomRepository
$roomRepository
)
:
Response
{
{
$sorting
=
$request
->
query
->
get
(
'sorting'
);
return
$this
->
render
(
'room/index.html.twig'
,
[
return
$this
->
render
(
'room/index.html.twig'
,
[
'rooms'
=>
$roomRepository
->
findAll
(),
'rooms'
=>
$roomRepository
->
findSorted
(
$sorting
),
'sorting'
=>
$sorting
]);
]);
}
}
...
...
src/Repository/RoomRepository.php
View file @
fb19fb6b
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
App\Repository
;
namespace
App\Repository
;
use
App\Entity\Reservation
;
use
App\Entity\Room
;
use
App\Entity\Room
;
use
Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository
;
use
Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository
;
use
Doctrine\Persistence\ManagerRegistry
;
use
Doctrine\Persistence\ManagerRegistry
;
...
@@ -19,6 +20,25 @@ class RoomRepository extends ServiceEntityRepository
...
@@ -19,6 +20,25 @@ class RoomRepository extends ServiceEntityRepository
parent
::
__construct
(
$registry
,
Room
::
class
);
parent
::
__construct
(
$registry
,
Room
::
class
);
}
}
/**
* @return Room[]
*/
public
function
findSorted
(
?
string
$sorting
)
:
array
{
$qb
=
$this
->
createQueryBuilder
(
'room'
);
if
(
'ASC'
===
$sorting
)
{
$qb
->
addOrderBy
(
'room.name'
,
'ASC'
);
}
elseif
(
'DESC'
===
$sorting
)
{
$qb
->
addOrderBy
(
'room.name'
,
'DESC'
);
}
$query
=
$qb
->
getQuery
();
return
$query
->
getResult
();
}
// /**
// /**
// * @return Room[] Returns an array of Room objects
// * @return Room[] Returns an array of Room objects
// */
// */
...
...
templates/room/index.html.twig
View file @
fb19fb6b
...
@@ -4,7 +4,16 @@
...
@@ -4,7 +4,16 @@
{%
block
body
%}
{%
block
body
%}
<h1>
Room index
</h1>
<h1>
Room index
</h1>
<form>
<label>
<select
name=
"sorting"
>
<option
value=
""
>
Brak
</option>
<option
value=
"ASC"
>
Spadająco
</option>
<option
value=
"DESC"
>
Rosnąco
</option>
</select>
</label>
<input
type=
"submit"
/>
</form>
<table
class=
"table"
>
<table
class=
"table"
>
<thead>
<thead>
<tr>
<tr>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment