fix: fix setup and dummy in case meilisearch not activated (monicahq/chandler#185)

This commit is contained in:
Alexis Saettler
2022-08-05 14:35:58 +02:00
committed by GitHub
parent c5939e0c31
commit 6a85bca727
15 changed files with 143 additions and 78 deletions
+16
View File
@@ -2,11 +2,14 @@
namespace App\Models;
use App\Helpers\ScoutHelper;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\MorphOne;
use Laravel\Scout\Attributes\SearchUsingFullText;
use Laravel\Scout\Attributes\SearchUsingPrefix;
use Laravel\Scout\Searchable;
class Group extends Model
@@ -31,7 +34,10 @@ class Group extends Model
* Get the indexable data array for the model.
*
* @return array
* @codeCoverageIgnore
*/
#[SearchUsingPrefix(['id', 'vault_id'])]
#[SearchUsingFullText(['name'])]
public function toSearchableArray(): array
{
return [
@@ -41,6 +47,16 @@ class Group extends Model
];
}
/**
* When updating a model, this method determines if we should update the search index.
*
* @return bool
*/
public function searchIndexShouldBeUpdated()
{
return ScoutHelper::activated();
}
/**
* Get the vault associated with the group.
*