Skip to content

Commit

Permalink
Merge devloops changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hi019 authored Nov 22, 2021
2 parents 9c49d71 + 9d21069 commit 490f220
Show file tree
Hide file tree
Showing 9 changed files with 599 additions and 157 deletions.
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,22 @@ This package makes it easy to add full text search support to your models with L


## Installation
The Typesense PHP SDK uses httplug to interface with various PHP HTTP libraries through a single API.

You can install the package via composer:
First, install the correct httplug adapter based on your `guzzlehttp/guzzle` version. For example, if you're on
Laravel 8, which includes Guzzle 7, then run this:

``` bash
```bash
composer require php-http/guzzle7-adapter
```

Then install the driver:

```bash
composer require typesense/laravel-scout-typesense-driver
```

Add the service provider:
And add the service provider:

```php
// config/app.php
Expand All @@ -49,7 +57,7 @@ Ensure you have Laravel Scout as a provider too otherwise you will get an "unres
],
```

Add `SCOUT_DRIVER=typesense` to your `.env` file
Add `SCOUT_DRIVER=typesense` to your `.env` file

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

Expand Down Expand Up @@ -187,7 +195,6 @@ $todos->searchable();
and changing the config/scout.php config key from `typesensesearch` to `typesense`
- Instead of importing `Devloops\LaravelTypesense\*`, you should import `Typesense\LaravelTypesense\*`
- Instead of models implementing `Devloops\LaravelTypesense\Interfaces\TypesenseSearch`, they should implement `Typesense\LaravelTypesense\Interfaces\TypesenseDocument`
- In the rare case where the `TypesenseEngine` method `delete` is called directly, all the model instances passed to the method must now belong to the same Typesense index

## Authors
This package was originally authored by [Abdullah Al-Faqeir](https://github.com/AbdullahFaqeir) and his company DevLoops: https://github.com/devloopsnet/laravel-scout-typesense-engine. It has since been adopted into the Typesense Github org.
Expand Down
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
"illuminate/support": "^7.0|^8.0",
"typesense/typesense-php": "^4.0"
},
"config": {
"platform": {
"php": "8.0"
}
},
"suggest": {
"typesense/typesense-php": "Required to use the Typesense php client."
},
Expand Down
49 changes: 49 additions & 0 deletions src/Classes/TypesenseDocumentIndexResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Typesense\LaravelTypesense\Classes;

/**
* Class TypesenseDocumentIndexResponse.
*
* @date 02/10/2021
*
* @author Abdullah Al-Faqeir <abdullah@devloops.net>
*/
class TypesenseDocumentIndexResponse
{
public function __construct(private ?int $code, private bool $success, private ?string $error = null, private ?array $document = null)
{
}

/**
* @return int|null
*/
public function getCode(): ?int
{
return $this->code;
}

/**
* @return bool
*/
public function isSuccess(): bool
{
return $this->success;
}

/**
* @return string|null
*/
public function getError(): ?string
{
return $this->error;
}

/**
* @return array|null
*/
public function getDocument(): ?array
{
return $this->document;
}
}
Loading

0 comments on commit 490f220

Please sign in to comment.