2017 © Pedro Peláez
 

library ink-sphinxize

Sphinx Search for Laravel 4 - InkSphinxize

image

ink/ink-sphinxize

Sphinx Search for Laravel 4 - InkSphinxize

  • Saturday, October 19, 2013
  • by orkhan
  • Repository
  • 1 Watchers
  • 2 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

InkSphinxize

Sphinx Search for Laravel 4 - InkSphinxize, (*1)

Installation

First, you'll need to add the package to the require attribute of your composer.json file:, (*2)

{
    "require": {
        "ink/ink-sphinxize": "dev-master"
    },
}

Afterwards, run composer update from your command line., (*3)

Then, add 'Ink\InkSphinxize\InkSphinxizeServiceProvider', to the list of service providers in app/config/app.php and add 'InkSphinxizeSearch' => 'Ink\InkSphinxize\Facades\InkSphinxize', to the list of class aliases in app/config/app.php., (*4)

From the command line again, run php artisan config:publish ink/ink-sphinxize., (*5)

Updating your Models

Define a private static property $sphinxize with the definitions:, (*6)


class Post extends Eloquent { use Ink\InkSphinxize\InkSphinxize; /** * The database table used by the model. * * @var string */ protected $table = 'posts'; /** * InkSphinxize configs * * @var array */ private static $sphinxize = [ 'index' => 'posts', 'pk' => 'id', 'perPage' => 15, ]; }

That's it!, (*7)

Examples


Route::get('/', function() { $perPage = 5; // Override $sphinxize perPage value $ids = Post::ss('Azerbaijan') ->ids() ->skip(5) ->take($perPage) ->get(); // Returns [2, 34, 66, 98, 103, ...] $records = Post::ss('Azerbaijan') ->limit(0, $perPage) ->get(); // Returns \Illuminate\Database\Eloquent\Collection $records = Post::ss('Azerbaijan') ->limit(0, $perPage) ->with('category') ->get(); // Returns \Illuminate\Database\Eloquent\Collection with Eager loading $records = Post::ss('Azerbaijan') ->with(array('category', 'tags' => function($query){ $query->where('name', 'like', '%baku%'); })) ->paginate($perPage); // Returns \Illuminate\Database\Eloquent\Collection with Eager loading $paginator = Paginator::make($records->toArray(), count($records->toArray()), $perPage); // Paginator dd($records); });

Bugs and Suggestions

Please use Github for bugs, comments, suggestions. Pull requests are preferred!, (*8)

InkSphinxize was written by Orkhan Maharramli and released under the MIT License. See the LICENSE file for details., (*9)

Copyright 2013 Orkhan Maharramli, (*10)

The Versions

19/10 2013

dev-master

9999999-dev https://github.com/orkhan/InkSphinxize

Sphinx Search for Laravel 4 - InkSphinxize

  Sources   Download

MIT

The Requires

 

by Avatar orkhan

laravel eloquent sphinx ink sphinxize