Closed aoeng closed 9 months ago
I change driver to anouther "algolia",but still so.The configuration file doesn't seem to be working
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.
我猜你的模型之一使用这个 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;
}
}
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.
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?
info('Stmts: ' ,[$stmts]);
return $nodeTraverser->traverse($stmts);
It seems to print out all my php code What happened?
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.
change app/Admin/bootstap.php
use Encore\Admin\Form as AdminForm;
use Encore\Admin\Grid as AdminGrid;
It looks good.
Search all files This design is a little anti-human,Is it that I give you something, and you import it?
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.
laravel 10.31 scout 10.5 laravel-scout-elasticsearch 7.4.0 encore/laravel-admin 1.8.19
The system runs properly on the local server(win11), but an error occurs when the system runs on the server(ubuntu)! How to fix it?