Git Product home page Git Product logo

Comments (10)

hkulekci avatar hkulekci commented on July 18, 2024 2

I don't know, we miss something. Okay. Let's look at the problem again from scratch.
The problem is caused by the fact that there are 2 Form classes in the same namespace. And You changed one of the names. But somehow, more is needed to solve the problem. You may need to give more clues to understand the problem. And I checked the codebase of this library. There is no class as Form. According to my understanding, the issue is beyond the scope of the library.

If you can give more information, we can reconsider the issue.

from laravel-scout-elasticsearch.

aoeng avatar aoeng commented on July 18, 2024

I change driver to anouther "algolia",but still so.The configuration file doesn't seem to be working

from laravel-scout-elasticsearch.

hkulekci avatar hkulekci commented on July 18, 2024

I guess one of your model using this Form class name some how. Find the line in your models and could you change "Encore\Admin\Form as Form" part as "Encore\Admin\Form as AdminForm" and use "AdminForm" instead of "Form" in that file.

from laravel-scout-elasticsearch.

aoeng avatar aoeng commented on July 18, 2024

我猜你的模型之一使用这个 Form 类名称是如何的。找到模型中的行,您是否可以将“Encore\Admin\Form as Form”部分更改为“Encore\Admin\Form as AdminForm”,并在该文件中使用“AdminForm”而不是“Form”。

NO!Are there any other solutions?thx

namespace App\Models;

use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Laravel\Scout\Searchable;
use Overtrue\LaravelPinyin\Facades\Pinyin;

class Concert extends Model
{
    use Searchable;


    public function searchableAs(): string
    {
        return 'concerts_index';
    }

    public function toSearchableArray(): array
    {
        $this->loadMissing(['people']);

        return [
            'name'          => $this->name,
            'name_pinyin'   => implode(' ', Pinyin::convert($this->name)),
            'people'        => $this->people->pluck('name')->implode(','),
            'people_pinyin' => $this->people->pluck('name')->transform(function ($name) {
                return [implode(' ', Pinyin::convert($name)), Pinyin::abbr($name)];
            })->toArray()
        ];
    }

    public function shouldBeSearchable(): bool
    {
        return $this->enabled;
    }
}

from laravel-scout-elasticsearch.

aoeng avatar aoeng commented on July 18, 2024

yes
composer.json

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The skeleton application for the Laravel framework.",
    "keywords": ["laravel", "framework"],
    "license": "MIT",
    "require": {
        "php": "^8.1",
        "aoeng/laravel-admin-advertisement": "^1.0",
        "aoeng/laravel-admin-article": "^1.0",
        "aoeng/laravel-admin-filesystem": "^1.2",
        "aoeng/laravel-admin-version": "^1.0",
        "encore/laravel-admin": "1.*",
        "guzzlehttp/guzzle": "^7.2",
        "iidestiny/laravel-filesystem-oss": "^3.3",
        "laravel-admin-ext/latlong": "1.x",
        "laravel/framework": "^10.10",
        "laravel/sanctum": "^3.2",
        "laravel/scout": "*",
        "laravel/tinker": "^2.8",
        "leonis/easysms-notification-channel": "^2.0",
        "matchish/laravel-scout-elasticsearch": "^7.4",
        "overtrue/laravel-pinyin": "^5.0",
        "overtrue/laravel-socialite": "^4.0",
        "propaganistas/laravel-phone": "^5.0"
    },
    "require-dev": {
        "fakerphp/faker": "^1.9.1",
        "knuckleswtf/scribe": "^4.25",
        "laravel-lang/common": "^4.0",
        "laravel/pint": "^1.0",
        "laravel/sail": "^1.18",
        "mockery/mockery": "^1.4.4",
        "nunomaduro/collision": "^7.0",
        "phpunit/phpunit": "^10.1",
        "spatie/laravel-ignition": "^2.0"
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-update-cmd": [
            "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true,
        "allow-plugins": {
            "pestphp/pest-plugin": true,
            "php-http/discovery": true
        }
    },
    "minimum-stability": "stable",
    "prefer-stable": true
}

models just one

namespace App\Models;

use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Laravel\Scout\Searchable;
use Overtrue\LaravelPinyin\Facades\Pinyin;

class Concert extends Model
{
    use Searchable;


    public function searchableAs(): string
    {
        return 'concerts_index';
    }

    public function toSearchableArray(): array
    {
        $this->loadMissing(['people']);

        return [
            'name'          => $this->name,
            'name_pinyin'   => implode(' ', Pinyin::convert($this->name)),
            'people'        => $this->people->pluck('name')->implode(','),
            'people_pinyin' => $this->people->pluck('name')->transform(function ($name) {
                return [implode(' ', Pinyin::convert($name)), Pinyin::abbr($name)];
            })->toArray()
        ];
    }

    public function shouldBeSearchable(): bool
    {
        return $this->enabled;
    }
}

scout.php

 'driver' => env('SCOUT_DRIVER', 'null'),

.env ,but change auouth one ,still so,config like not working.

SCOUT_DRIVER=Matchish\ScoutElasticSearch\Engines\ElasticSearchEngine

system ubuntu,It is working in windows.
Can you repeat the question?
Do you need anything else?

from laravel-scout-elasticsearch.

aoeng avatar aoeng commented on July 18, 2024
  info('Stmts: ' ,[$stmts]);
  return $nodeTraverser->traverse($stmts);

It seems to print out all my php code
What happened?

from laravel-scout-elasticsearch.

hkulekci avatar hkulekci commented on July 18, 2024

I just tried with your sharing :

Importing [App\Models\Concert]
Switching to the new index
5/5 [⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬] 100%

                                                                                                                        
 [OK] All [App\Models\Concert] records have been imported.                                                              

Everything works fine for me. I guess there should be a People model somewhere. And that model uses something related to Form.

It seems to print out all my php code
What happened?

This library loops on your project file to find the Models which are Searchable. And import them. You can check the Matchish\ScoutElasticSearch\Console\Commands\ImportCommand as well.

from laravel-scout-elasticsearch.

aoeng avatar aoeng commented on July 18, 2024

change app/Admin/bootstap.php

use Encore\Admin\Form as AdminForm;
use Encore\Admin\Grid as AdminGrid;

It looks good.

from laravel-scout-elasticsearch.

aoeng avatar aoeng commented on July 18, 2024

Search all files This design is a little anti-human,Is it that I give you something, and you import it?

from laravel-scout-elasticsearch.

hkulekci avatar hkulekci commented on July 18, 2024

I am afraid I could not understand exactly what you mean but you can feel free to raise a PR with better solution as well. That part just looping to find classes which are using Searchable trait to be able import it into ES.

from laravel-scout-elasticsearch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.