Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Зуев Егор
/
wiki.dev
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
Nick Walke
2016-03-04 02:33:57 -0600
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
33bf20cfc8e0903da0df4f17481d2a47a9a3ddb5
33bf20cf
1 parent
5681f4dd
Found the source of the issue, not sure how to fix
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
app/Entity.php
app/Repos/PageRepo.php
app/Entity.php
View file @
33bf20c
...
...
@@ -100,10 +100,14 @@ abstract class Entity extends Model
*/
public
static
function
fullTextSearchQuery
(
$fieldsToSearch
,
$terms
,
$wheres
=
[])
{
$termString
=
''
;
foreach
(
$terms
as
$term
)
{
$termString
.=
htmlentities
(
$term
)
.
'* '
;
foreach
(
$terms
as
$key
=>
$term
)
{
$term
=
htmlentities
(
$term
);
if
(
preg_match
(
'/\s/'
,
$term
))
{
$term
=
'"'
.
$term
.
'"'
;
}
$terms
[
$key
]
=
$term
.
'*'
;
}
$termString
=
"'"
.
implode
(
' '
,
$terms
)
.
"'"
;
$fields
=
implode
(
','
,
$fieldsToSearch
);
$termStringEscaped
=
\DB
::
connection
()
->
getPdo
()
->
quote
(
$termString
);
$search
=
static
::
addSelect
(
\DB
::
raw
(
'*, MATCH(name) AGAINST('
.
$termStringEscaped
.
' IN BOOLEAN MODE) AS title_relevance'
));
...
...
@@ -113,9 +117,8 @@ abstract class Entity extends Model
foreach
(
$wheres
as
$whereTerm
)
{
$search
->
where
(
$whereTerm
[
0
],
$whereTerm
[
1
],
$whereTerm
[
2
]);
}
// Load in relations
if
(
static
::
isA
(
'page'
))
{
if
(
static
::
isA
(
'page'
))
{
$search
=
$search
->
with
(
'book'
,
'chapter'
,
'createdBy'
,
'updatedBy'
);
}
else
if
(
static
::
isA
(
'chapter'
))
{
$search
=
$search
->
with
(
'book'
);
...
...
app/Repos/PageRepo.php
View file @
33bf20c
...
...
@@ -208,7 +208,9 @@ class PageRepo
}
else
{
$terms
=
[];
}
$terms
=
array_merge
(
$terms
,
explode
(
' '
,
$term
));
if
(
!
empty
(
$term
))
{
$terms
=
array_merge
(
$terms
,
explode
(
' '
,
$term
));
}
$pages
=
$this
->
page
->
fullTextSearchQuery
([
'name'
,
'text'
],
$terms
,
$whereTerms
)
->
paginate
(
$count
)
->
appends
(
$paginationAppends
);
...
...
Please
register
or
sign in
to post a comment