File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
src/app/Library/CrudPanel/Traits Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 22
33namespace Backpack \CRUD \app \Library \CrudPanel \Traits ;
44
5+ use Illuminate \Contracts \Database \Query \Builder as QueryBuilder ;
56use Illuminate \Database \Eloquent \Builder ;
67
78trait Query
@@ -63,6 +64,13 @@ public function addBaseClause($function)
6364 return $ this ;
6465 }
6566
67+ public function setQuery (QueryBuilder $ query )
68+ {
69+ $ this ->query = $ query ;
70+
71+ return $ this ;
72+ }
73+
6674 /**
6775 * Use eager loading to reduce the number of queries on the table view.
6876 *
Original file line number Diff line number Diff line change @@ -180,4 +180,12 @@ public function testItGetTheQueryCountFromAPreviousCount()
180180
181181 $ this ->assertEquals (5 , $ this ->crudPanel ->getTotalQueryCount ());
182182 }
183+ public function testItCanSetTheQueryOnTheCrudPanel ()
184+ {
185+ $ this ->assertEquals (User::query ()->toSql (), $ this ->crudPanel ->query ->toSql ());
186+
187+ $ this ->crudPanel ->setQuery (User::query ()->where ('id ' , 1 ));
188+
189+ $ this ->assertEquals (User::query ()->where ('id ' , 1 )->toSql (), $ this ->crudPanel ->query ->toSql ());
190+ }
183191}
You can’t perform that action at this time.
0 commit comments