teamtnt / laravel-scout-tntsearch-driver

Driver for Laravel Scout search package based on https://github.com/teamtnt/tntsearch
MIT License
1.1k stars 144 forks source link

Facade removed. Correct way to index models in Laravel with v1.0.7? #122

Closed marleybobby closed 7 years ago

marleybobby commented 7 years ago

I followed this tutorial http://tnt.studio/blog/searching-for-bobby-fisher-with-laravel-5 but it seems that there isn't any facade provided, so how can I translate this

public static function insertToIndex($model)
    {
        TNTSearch::selectIndex('mymodel.index');
        $index = TNTSearch::getIndex();
        $index->insert($model->toArray());
    }

to a working piece of code?

Is my approach correct, or is there a better one?

$tnt = new TNTSearch;
        $tnt->selectIndex('mymodel.index');
        $index = $tnt->getIndex();
        $index->insert($model->toArray());

And why isn't there a facade like in that tutorial described? It seems that the Facade was removed with version 1.0.0. So what the correct way to call the Indexer in Laravel?

stokic commented 7 years ago

Did you add. a facade like tutorial suggests? And is. the facade included in the autoload file? If not then you skipped a step, perhaps artisan optmize? On Sat, 4 Nov 2017 at 17:38, marleybobby notifications@github.com wrote:

I followed this tutorial http://tnt.studio/blog/searching-for-bobby-fisher-with-laravel-5 but it seems that there isn't any facade provided, so how can I translate this

public static function insertToIndex($model) { TNTSearch::selectIndex('mymodel.index'); $index = TNTSearch::getIndex(); $index->insert($model->toArray()); }

to a working piece of code?

Is my approach correct, or is there a better one?

$tnt = new TNTSearch; $tnt->selectIndex('mymodel.index'); $index = $tnt->getIndex(); $index->insert($model->toArray());

And why isn't there a facade like in that tutorial described?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/teamtnt/laravel-scout-tntsearch-driver/issues/122, or mute the thread https://github.com/notifications/unsubscribe-auth/ACDDWsV0LVuU5enbg5g52S2JjuQMJAWAks5szJMYgaJpZM4QSEZ2 .

marleybobby commented 7 years ago

I tried to add 'TNTSearch' => TeamTNT\TNTSearch\Facades\TNTSearch::class, but there isn't a directory called Facade in that folder. So I'm not able to include sth. what isn't available.

It seems that the Facade was removed with version 1.0. So what the correct way to call the indexer?

nticaric commented 7 years ago

The facade has been removed when laravel introduced scout and isn't necessary anymore. I guess we should update the tutorial

marleybobby commented 7 years ago

Just figured out the same. There isn't any need to manually handle it, scout will do it for you.

An update or a notice would be great.

nticaric commented 7 years ago

@marleybobby we just updated the tutorial, please try to follow it again and let us know if we skipped any steps.

http://tnt.studio/blog/searching-for-bobby-fisher-with-laravel-5

marleybobby commented 7 years ago

Seems good to me. Found out the same approach.