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
4650a38d
Commit
4650a38d
authored
Oct 27, 2021
by
Lech Sawon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
search by like query
parent
f8e57532
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
3 deletions
+15
-3
RoomController.php
src/Controller/RoomController.php
+4
-2
RoomRepository.php
src/Repository/RoomRepository.php
+6
-1
index.html.twig
templates/room/index.html.twig
+5
-0
No files found.
src/Controller/RoomController.php
View file @
4650a38d
...
...
@@ -21,10 +21,12 @@ class RoomController extends AbstractController
public
function
index
(
Request
$request
,
RoomRepository
$roomRepository
)
:
Response
{
$sorting
=
$request
->
query
->
get
(
'sorting'
);
$queryString
=
$request
->
query
->
get
(
'search'
);
return
$this
->
render
(
'room/index.html.twig'
,
[
'rooms'
=>
$roomRepository
->
findSorted
(
$sorting
),
'sorting'
=>
$sorting
'rooms'
=>
$roomRepository
->
findSorted
(
$sorting
,
$queryString
),
'sorting'
=>
$sorting
,
'queryString'
=>
$queryString
]);
}
...
...
src/Repository/RoomRepository.php
View file @
4650a38d
...
...
@@ -23,7 +23,7 @@ class RoomRepository extends ServiceEntityRepository
/**
* @return Room[]
*/
public
function
findSorted
(
?
string
$sorting
)
:
array
public
function
findSorted
(
?
string
$sorting
,
?
string
$queryString
)
:
array
{
$qb
=
$this
->
createQueryBuilder
(
'room'
);
...
...
@@ -34,6 +34,11 @@ class RoomRepository extends ServiceEntityRepository
$qb
->
addOrderBy
(
'room.name'
,
'DESC'
);
}
if
(
$queryString
)
{
$qb
->
andWhere
(
'room.name LIKE :queryString'
);
$qb
->
setParameter
(
':queryString'
,
"%
$queryString
%"
);
}
$query
=
$qb
->
getQuery
();
return
$query
->
getResult
();
...
...
templates/room/index.html.twig
View file @
4650a38d
...
...
@@ -5,6 +5,11 @@
{%
block
body
%}
<h1>
Room index
</h1>
{{
include
(
'_embed/_simple_sorting.html.twig'
)
}}
<form>
<input
type=
"text"
name=
"search"
/>
<input
type=
"submit"
/>
</form>
<table
class=
"table"
>
<thead>
<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