@@ -600,4 +600,31 @@ public function it_includes_a_model_identifier_to_search_results()
600600 $ this ->assertEquals ($ search ->toArray ()['data ' ][0 ]['type ' ], class_basename (Post::class));
601601 $ this ->assertEquals ($ search ->toArray ()['data ' ][1 ]['type ' ], class_basename (Video::class));
602602 }
603+
604+ /** @test */
605+ public function it_supports_full_text_search ()
606+ {
607+ $ postA = Post::create (['title ' => 'Laravel Framework ' ]);
608+ $ postB = Post::create (['title ' => 'Tailwind Framework ' ]);
609+
610+ $ blogA = Blog::create (['title ' => 'Laravel Framework ' , 'subtitle ' => 'PHP ' , 'body ' => 'Ad nostrud adipisicing deserunt labore reprehenderit ' ]);
611+ $ blogB = Blog::create (['title ' => 'Tailwind Framework ' , 'subtitle ' => 'CSS ' , 'body ' => 'aute do commodo ea magna dolor cupidatat ullamco commodo. ' ]);
612+
613+ $ pageA = Page::create (['title ' => 'Laravel Framework ' , 'subtitle ' => 'PHP ' , 'body ' => 'Ad nostrud adipisicing deserunt labore reprehenderit ' ]);
614+ $ pageB = Page::create (['title ' => 'Tailwind Framework ' , 'subtitle ' => 'CSS ' , 'body ' => 'aute do commodo ea magna dolor cupidatat ullamco commodo. ' ]);
615+
616+ $ results = Search::new ()
617+ ->beginWithWildcard ()
618+ ->add (Post::class, 'title ' )
619+ ->addFullText (Blog::class, ['title ' , 'subtitle ' , 'body ' ], ['mode ' => 'boolean ' ])
620+ ->addFullText (Page::class, ['title ' , 'subtitle ' , 'body ' ], ['mode ' => 'boolean ' ])
621+ ->get ('framework -css ' );
622+
623+ $ this ->assertCount (4 , $ results );
624+
625+ $ this ->assertTrue ($ results ->contains ($ postA ));
626+ $ this ->assertTrue ($ results ->contains ($ postB ));
627+ $ this ->assertTrue ($ results ->contains ($ blogA ));
628+ $ this ->assertTrue ($ results ->contains ($ pageA ));
629+ }
603630}
0 commit comments