brunoquaresma / laravel-dbsearch
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 10
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/brunoquaresma/laravel-dbsearch
Requires
- php: >=5.3.0
- illuminate/support: 4.1.*
This package is not auto-updated.
Last update: 2025-10-21 11:23:50 UTC
README
A simple package for full text search using the Laravel's Eloquent.
Required setup
In the require key of composer.json file add the following
"brunoquaresma/laravel-dbsearch": "dev-master"
Run the Composer update comand
$ composer update
In your config/app.php add 'Brunoquaresma\LaravelDBSearch\LaravelDBSearchServiceProvider' to the end of the $providers array
'providers' => array( 'Illuminate\Foundation\Providers\ArtisanServiceProvider', 'Illuminate\Auth\AuthServiceProvider', ... 'Brunoquaresma\LaravelDBSearch\LaravelDBSearchServiceProvider', ),
At the end of config/app.php add 'LaravelDBSearch' => 'Brunoquaresma\LaravelDBSearch\Facades\LaravelDBSearch' to the $aliases array
'aliases' => array( 'App' => 'Illuminate\Support\Facades\App', 'Artisan' => 'Illuminate\Support\Facades\Artisan', ... 'LaravelDBSearch' => 'Brunoquaresma\LaravelDBSearch\Facades\LaravelDBSearch' ),
###Basic usage
For this example we use a course model.
$courses = LaravelDBSearch::model('Course') ->field(array('name', 'description')) ->query('php') ->get();
- model() - Set the default model for the search.
- field() - Set the search fields by array or a string value if have only one field.
- query() - Set the search query value.
- get() - Get the results of search.
###Use join
Get the courses where the owner have a name with John.
$courses = LaravelDBSearch::model('Course') ->field(array('name', 'description', 'first_name', 'last_name', 'username')) ->join('courses.*', 'users', 'courses.user_id', '=', 'users.id') ->query('John') ->get();