Skip to content

Commit

Permalink
eloquentsearch v1 base copy now working with joins for orderby
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Blake committed Jan 15, 2016
0 parents commit 5421a48
Show file tree
Hide file tree
Showing 7 changed files with 566 additions and 0 deletions.
18 changes: 18 additions & 0 deletions assemble/eloquentsearch/README.md
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.

20 changes: 20 additions & 0 deletions assemble/eloquentsearch/composer.json
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"
}
}
}
24 changes: 24 additions & 0 deletions assemble/eloquentsearch/config/eloquent_search.php
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 assemble/eloquentsearch/src/EloquentSearchServiceProvider.php
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;
});
}


}
23 changes: 23 additions & 0 deletions assemble/eloquentsearch/src/Facades/EloquentSearcher.php
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';
}
}
23 changes: 23 additions & 0 deletions assemble/eloquentsearch/src/Facades/Searcher.php
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';
}
}
Loading

0 comments on commit 5421a48

Please sign in to comment.