I am setting up search in my project.which includes more than one model to search.Firstly, I tried using scout and scout extended but it does not give much flexibility with where clause.so I thought to have a look to composer require spatie/laravel-searchable
but it seems its dependency is laravel 5.8
.
but my laravel
version is 5.7.28
.Please provide me the solution.
How should I proceed with the same?
I tried using scout and scout extended but it does not give much flexibility with where clause
$channels = Channel::where('created_at', '>', now()->subDays(7))->get();
return view('search.index')->with(compact('channels'));
this works perfectly as this is simple query but if I try the same with the scout and algolia(search request)
$channels = Channel::search($request->q)->where('created_at', '>', now()-
>subDays(7))->get();
it does not give any result.
when I tried installing composer require spatie/laravel-searchable
I got this error
Problem 1
- Can only install one of: laravel/framework[v5.7.28, 5.8.x-dev].
- Can only install one of: laravel/framework[5.8.x-dev, v5.7.28].
- Can only install one of: laravel/framework[5.8.x-dev, v5.7.28].
- spatie/laravel-searchable 1.3.0 requires laravel/framework ~5.8.0 -> satisfiable by laravel/framework[5.8.x-dev].
- Installation request for spatie/laravel-searchable ^1.3 -> satisfiable by spatie/laravel-searchable[1.3.0].
- Installation request for laravel/framework (locked at v5.7.28, required as 5.7.*) -> satisfiable by laravel/framework[v5.7.28].
Laravel 5.7 support droped with v1.3.0
so you need to install the older version.
Changelog: https://github.com/spatie/laravel-searchable/blob/master/CHANGELOG.md
You can install the older version using command:
composer require spatie/laravel-searchable:1.2.3
Or add this version into your composer.json
file and run composer update