Skip to content

Commit 5fe4d71

Browse files
committed
improve query contents command and fixed tests
improve query contents command querying with terms context to support string
1 parent 29a4697 commit 5fe4d71

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/Darryldecode/Backend/Components/ContentBuilder/Commands/QueryContentsCommand.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,16 @@ protected function query($contentType, $content)
190190
$q->whereHas('taxonomy', function ($q) use ($k)
191191
{
192192
$q->where('taxonomy', $k);
193-
})->whereIn('slug',$v);
193+
});
194+
195+
if( is_string($v) )
196+
{
197+
$q->where('slug',$v);
198+
}
199+
else
200+
{
201+
$q->whereIn('slug',$v);
202+
}
194203
});
195204
}
196205
}

tests/ContentBuilder/functional/commands/QueryContentsCommandTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ public function testQueryWithTermButTermsIsNotAssociatedWithAnyPost()
9797
'Darryldecode\Backend\Components\ContentBuilder\Commands\QueryContentsCommand',
9898
array(
9999
'type' => 'Blog',
100-
'terms' => 'technology'
100+
'terms' => array(
101+
'category' => 'technology'
102+
)
101103
)
102104
);
103105

@@ -131,7 +133,9 @@ public function testQueryWithTerms()
131133
'Darryldecode\Backend\Components\ContentBuilder\Commands\QueryContentsCommand',
132134
array(
133135
'type' => 'Blog',
134-
'terms' => 'programming:health'
136+
'terms' => array(
137+
'category' => 'health'
138+
)
135139
)
136140
);
137141

0 commit comments

Comments
 (0)