1. Go to this page and download the library: Download ditscheri/eloquent-search library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ditscheri / eloquent-search example snippets
class Podcast extends Model
{
use \Ditscheri\EloquentSearch\Searchable;
/**
* The attributes that are searchable.
*
* @var string[]
*/
protected array $searchable = [
'title', // make sure to add proper indexes to each of these columns
'description',
'author.first_name',
'author.last_name',
'comments.message',
'series.title',
'series.tags.name',
];
public function author()
{
return $this->belongsTo(User::class);
}
public function comments()
{
return $this->hasMany(Comment::class);
}
public function series()
{
return $this->belongsTo(Series::class);
}
}
class PodcastController
{
public function index(Request $request)
{
return Podcast::search($request->input('q', null))->paginate();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.