fix: fix setup and dummy in case meilisearch not activated (monicahq/chandler#185)
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user