Skip to content

Commit 5421a48

Browse files
author
Alex Blake
committed
eloquentsearch v1 base copy now working with joins for orderby
0 parents  commit 5421a48

File tree

7 files changed

+566
-0
lines changed

7 files changed

+566
-0
lines changed

assemble/eloquentsearch/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Eloquent Model Searcher for Laravel 5
2+
3+
## Instalation
4+
5+
Add this line to your `providers` array:
6+
``` php
7+
Assemble\EloquentSearch\EloquentSearchServiceProvider::class,
8+
```
9+
10+
Add this line to your `aliases` array:
11+
``` php
12+
'EloquentSearch' => Assemble\EloquentSearch\Facades\EloquentSearcher::class,
13+
```
14+
15+
You will need to run `php artisan vendor:publish` to publish the config file to your instalation,
16+
Once run, you can find it in `config/eloquenet_search.php`.
17+
This config file is used to controll which models are used to search/return entities of.
18+

assemble/eloquentsearch/composer.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "assemble/eloquentsearch",
3+
"description": "Search and retrieve an eloquent model entity based on complex search criteria from the model relations.",
4+
"type": "Library",
5+
"require": {
6+
},
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Alex Blake",
11+
"email": "[email protected]"
12+
}
13+
],
14+
"minimum-stability": "dev",
15+
"autoload": {
16+
"psr-4": {
17+
"Assemble\\EloquentSearch\\": "src"
18+
}
19+
}
20+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Config file to store the requestable entities for searching functionality.
4+
* This config maps the item call to their respective class instance to be used in constructing the query.
5+
**/
6+
return [
7+
'search_models' => [
8+
/*
9+
Add your searchable eloquent models here, this is an example of user model usage.
10+
11+
If you have your models sitting in the app root as default, something like this should find them.
12+
13+
'user' => User::class,
14+
15+
Otherwise if you have them elsewhere or the application cant seem to find them, try prefix them as such.
16+
17+
'user' => App\Models\User::class,
18+
19+
*/
20+
21+
'user' => User::class,
22+
23+
]
24+
];
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace Assemble\EloquentSearch;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
7+
class EloquentSearchServiceProvider extends ServiceProvider
8+
{
9+
/**
10+
* Bootstrap the application services.
11+
*
12+
* @return void
13+
*/
14+
public function boot()
15+
{
16+
$this->setupConfig();
17+
}
18+
19+
20+
/**
21+
* Setup the config.
22+
*
23+
* @return void
24+
*/
25+
protected function setupConfig()
26+
{
27+
$source = realpath(__DIR__.'/../config/eloquent_search.php');
28+
29+
$this->publishes([$source => config_path('eloquent_search.php')]);
30+
31+
$this->mergeConfigFrom($source, 'eloquent_search');
32+
}
33+
34+
/**
35+
* Register the application services.
36+
*
37+
* @return void
38+
*/
39+
public function register()
40+
{
41+
$this->app->bind('eloquentsearch.searcher', function ($app) {
42+
return new Searcher;
43+
});
44+
}
45+
46+
47+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Assemble\EloquentSearch\Facades;
4+
5+
use Illuminate\Support\Facades\Facade;
6+
7+
/**
8+
* This is the authorizer facade class.
9+
*
10+
* @author Alex Blake <[email protected]>
11+
*/
12+
class EloquentSearcher extends Facade
13+
{
14+
/**
15+
* Get the registered name of the component.
16+
*
17+
* @return string
18+
*/
19+
protected static function getFacadeAccessor()
20+
{
21+
return 'eloquentsearch.searcher';
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Assemble\EloquentSearch\Facades;
4+
5+
use Illuminate\Support\Facades\Facade;
6+
7+
/**
8+
* This is the authorizer facade class.
9+
*
10+
* @author Alex Blake <[email protected]>
11+
*/
12+
class EloquentSearcher extends Facade
13+
{
14+
/**
15+
* Get the registered name of the component.
16+
*
17+
* @return string
18+
*/
19+
protected static function getFacadeAccessor()
20+
{
21+
return 'eloquentsearch.searcher';
22+
}
23+
}

0 commit comments

Comments
 (0)