diff --git a/Packages/User/laravel_model.sublime-snippet b/Packages/User/laravel_model.sublime-snippet index c10a1c3..70007ae 100644 --- a/Packages/User/laravel_model.sublime-snippet +++ b/Packages/User/laravel_model.sublime-snippet @@ -4,9 +4,11 @@ use App\Models\Traits\HasUidTrait; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Prunable; +use Laravel\Scout\Searchable; use HasUidTrait; use Prunable; +use Searchable; /** @var string */ protected \$table = ''; @@ -78,6 +80,58 @@ protected function pruning(): void // } +/** + * Get the value used to index the model. + * + * @since 1.0.0 + * + * @return mixed + */ +public function getScoutKey() +{ + return \$this->id; +} + +/** + * Get the key name used to index the model. + * + * @since 1.0.0 + * + * @return string + */ +public function getScoutKeyName(): string +{ + return 'id'; +} + +/** + * Get the name of the index associated with the model. + * + * @since 1.0.0 + * + * @return string + */ +public function searchableAs(): string +{ + return 'models_index'; +} + +/** + * Get the indexable data array for the model. + * + * @since 1.0.0 + * + * @return array + */ +public function toSearchableArray(): array +{ + \$payload = \$this->toArray(); + + // modify here... + + return \$payload; +} + /* |-------------------------------------------------------------------------- | Accessors @@ -95,7 +149,7 @@ protected function pruning(): void protected function attrName(): Attribute { return Attribute::make( - get: fn ($value, $attributes) => $attributes['foo'], + get: fn (\$value, \$attributes) => \$attributes['foo'], ); }