exdeliver/elastic
Composer 安装命令:
composer require exdeliver/elastic
包简介
:package_description
关键字:
README 文档
README
Elasticsearch for Laravel Resources
Installation
Via Composer
$ composer require exdeliver/elastic
Usage
Create a resource and define the data to be imported by resources.
php artisan make:resource PhoneNumberResource
<?php
namespace App\Http\Resources;
use App\Models\PhoneNumber;
use Exdeliver\Elastic\Resources\ElasticSearchResource;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
class PhoneNumberResource extends ElasticSearchResource
{
public const ELASTIC_INDEX = 'phone_numbers';
public static function model(): Model
{
return new PhoneNumber();
}
public function toElastic(Request $request): array
{
/**
* Data from the model that should be imported
*/
return [
'index' => self::ELASTIC_INDEX,
'body' => [
'uuid' => $this->uuid,
'number' => $this->phonenumber,
'contact' => ContactResource::make($this->contact), // supports make() and collection()
],
];
}
public static function elastic(): array
{
return [
'index' => self::ELASTIC_INDEX,
];
}
}
Your controllewr
Change log
Please see the changelog for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email author@email.com instead of using the issue tracker.
Credits
License
MIT. Please see the license file for more information.
elastic
统计信息
- 总下载量: 1.58k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-10-06