-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eloquentsearch v1 base copy now working with joins for orderby
- Loading branch information
Alex Blake
committed
Jan 15, 2016
0 parents
commit 5421a48
Showing
7 changed files
with
566 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Eloquent Model Searcher for Laravel 5 | ||
|
||
## Instalation | ||
|
||
Add this line to your `providers` array: | ||
``` php | ||
Assemble\EloquentSearch\EloquentSearchServiceProvider::class, | ||
``` | ||
|
||
Add this line to your `aliases` array: | ||
``` php | ||
'EloquentSearch' => Assemble\EloquentSearch\Facades\EloquentSearcher::class, | ||
``` | ||
|
||
You will need to run `php artisan vendor:publish` to publish the config file to your instalation, | ||
Once run, you can find it in `config/eloquenet_search.php`. | ||
This config file is used to controll which models are used to search/return entities of. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "assemble/eloquentsearch", | ||
"description": "Search and retrieve an eloquent model entity based on complex search criteria from the model relations.", | ||
"type": "Library", | ||
"require": { | ||
}, | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Alex Blake", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"autoload": { | ||
"psr-4": { | ||
"Assemble\\EloquentSearch\\": "src" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/** | ||
* Config file to store the requestable entities for searching functionality. | ||
* This config maps the item call to their respective class instance to be used in constructing the query. | ||
**/ | ||
return [ | ||
'search_models' => [ | ||
/* | ||
Add your searchable eloquent models here, this is an example of user model usage. | ||
If you have your models sitting in the app root as default, something like this should find them. | ||
'user' => User::class, | ||
Otherwise if you have them elsewhere or the application cant seem to find them, try prefix them as such. | ||
'user' => App\Models\User::class, | ||
*/ | ||
|
||
'user' => User::class, | ||
|
||
] | ||
]; |
47 changes: 47 additions & 0 deletions
47
assemble/eloquentsearch/src/EloquentSearchServiceProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Assemble\EloquentSearch; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
|
||
class EloquentSearchServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Bootstrap the application services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
$this->setupConfig(); | ||
} | ||
|
||
|
||
/** | ||
* Setup the config. | ||
* | ||
* @return void | ||
*/ | ||
protected function setupConfig() | ||
{ | ||
$source = realpath(__DIR__.'/../config/eloquent_search.php'); | ||
|
||
$this->publishes([$source => config_path('eloquent_search.php')]); | ||
|
||
$this->mergeConfigFrom($source, 'eloquent_search'); | ||
} | ||
|
||
/** | ||
* Register the application services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
$this->app->bind('eloquentsearch.searcher', function ($app) { | ||
return new Searcher; | ||
}); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Assemble\EloquentSearch\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
/** | ||
* This is the authorizer facade class. | ||
* | ||
* @author Alex Blake <[email protected]> | ||
*/ | ||
class EloquentSearcher extends Facade | ||
{ | ||
/** | ||
* Get the registered name of the component. | ||
* | ||
* @return string | ||
*/ | ||
protected static function getFacadeAccessor() | ||
{ | ||
return 'eloquentsearch.searcher'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Assemble\EloquentSearch\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
/** | ||
* This is the authorizer facade class. | ||
* | ||
* @author Alex Blake <[email protected]> | ||
*/ | ||
class EloquentSearcher extends Facade | ||
{ | ||
/** | ||
* Get the registered name of the component. | ||
* | ||
* @return string | ||
*/ | ||
protected static function getFacadeAccessor() | ||
{ | ||
return 'eloquentsearch.searcher'; | ||
} | ||
} |
Oops, something went wrong.