laravel-scout-tntsearch-driver icon indicating copy to clipboard operation
laravel-scout-tntsearch-driver copied to clipboard

php artisan tntsearch:import ModelName OR php artisan scout:import ModelName both are not working.

Open faizan-glowlogix opened this issue 4 years ago • 12 comments

Hi there,

Help please it urgent..

I am implementing it. but when ever i run php artisan tntsearch:import ModelName OR php artisan scout:import ModelName

it gives me this error.

 Class 'ModelName' not found

  at C:\laragon\www\project\vendor\teamtnt\laravel-scout-tntsearch-driver\src\Console\ImportCommand.php:37
    33|     public function handle(Dispatcher $events)
    34|     {
    35|         $class = $this->argument('model');
    36|
  > 37|         $model = new $class();
    38|         dd($class);
    39|         $tnt = new TNTSearch();
    40|         $driver = $model->getConnectionName() ?: config('database.default');
    41|

  • A class import is missing: You have a missing class import. Try importing this class: `App\Models\CarIn`.

  1   C:\laragon\www\amjad-motors\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:37
      TeamTNT\Scout\Console\ImportCommand::handle(Object(Illuminate\Events\Dispatcher))

  2   C:\laragon\www\amjad-motors\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:37
      call_user_func_array()

Please share what is the problem here...

faizan-glowlogix avatar Feb 19 '21 20:02 faizan-glowlogix

My packages Details

"laravel/framework": "^7.0", "laravel/scout": "^8.6", "teamtnt/laravel-scout-tntsearch-driver": "^11.1"

faizan-glowlogix avatar Feb 19 '21 20:02 faizan-glowlogix

Obviously class not found like the error says.

What steps did you take in order to debug the situation?

On Fri, 19 Feb 2021 at 21:25, faizan-glowlogix [email protected] wrote:

My packages Details

"laravel/framework": "^7.0", "laravel/scout": "^8.6", "teamtnt/laravel-scout-tntsearch-driver": "^11.1"

— 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/311#issuecomment-782322690, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQMGWTV62YC6Y2EITNG4J3S73CKZANCNFSM4X463ASA .

stokic avatar Feb 19 '21 20:02 stokic

i am searching on it.. but didn't find anything to debug it.. as my model class working fine in controller and other places.

faizan-glowlogix avatar Feb 19 '21 20:02 faizan-glowlogix

Write here exactly what you enter in the command line and show your folder structure plus model namespace

On Fri, 19 Feb 2021 at 22:00, faizan-glowlogix [email protected] wrote:

i am searching on it.. but didn't find anything to debug it.. as my model class working fine in controller and other places.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/teamtnt/laravel-scout-tntsearch-driver/issues/311#issuecomment-782347654, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQMGWV4NMFCRY3PFXLCDHLS73GM7ANCNFSM4X463ASA .

stokic avatar Feb 19 '21 21:02 stokic

image

My folder Structure.. one change i have done is here.. before my models were in app directory... i moved them in App\Models Directory.

faizan-glowlogix avatar Feb 19 '21 21:02 faizan-glowlogix

After that i run this command composer require teamtnt/laravel-scout-tntsearch-driver

Configure this package same as given in the first page..

Add the service provider:

// config/app.php 'providers' => [ // ... TeamTNT\Scout\TNTSearchScoutServiceProvider::class, ], Ensure you have Laravel Scout as a provider too otherwise you will get an "unresolvable dependency" error

// config/app.php 'providers' => [ // ... Laravel\Scout\ScoutServiceProvider::class, ], Add SCOUT_DRIVER=tntsearch to your .env file

Then you should publish scout.php configuration file to your config directory

php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider" In your config/scout.php add:

'tntsearch' => [ 'storage' => storage_path(), //place where the index files will be stored 'fuzziness' => env('TNTSEARCH_FUZZINESS', false), 'fuzzy' => [ 'prefix_length' => 2, 'max_expansions' => 50, 'distance' => 2 ], 'asYouType' => false, 'searchBoolean' => env('TNTSEARCH_BOOLEAN', false), 'maxDocs' => env('TNTSEARCH_MAX_DOCS', 500), ],

Same these steps.

faizan-glowlogix avatar Feb 19 '21 21:02 faizan-glowlogix

after that i run php artisan scout:import App\Models\CarIn image

faizan-glowlogix avatar Feb 19 '21 21:02 faizan-glowlogix

Following this video https://www.youtube.com/watch?v=yuG1kS9WFz0&t=4s

faizan-glowlogix avatar Feb 19 '21 21:02 faizan-glowlogix

NameSpace

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Laravel\Scout\Searchable;

class CarIn extends Model

faizan-glowlogix avatar Feb 19 '21 21:02 faizan-glowlogix

The error says it all, there is no namespace app, there is App...

On Fri, 19 Feb 2021 at 22:40, faizan-glowlogix [email protected] wrote:

NameSpace

, or unsubscribe .

stokic avatar Feb 19 '21 21:02 stokic

Thanks for the help it is resolved. the problem is with the backslash

php artisan scout:import App\Models\CarIn it is working

php artisan scout:import App\\Models\\CarIn it is not

faizan-glowlogix avatar Feb 19 '21 22:02 faizan-glowlogix

You can also use php artisan scout:import "App\Models\CarIn"

simion-chis avatar Aug 04 '21 07:08 simion-chis