feat: Phase 5.2 - Global Search with Laravel Scout
- Install laravel/scout with database driver - Add Searchable trait to Feature, Issue, Task, Inspection models - Create GlobalSearch Livewire component with Blade view - Configure scout.php for database driver + queued syncing - Add SCOUT_DRIVER=database to .env.example Tests: 101 passing (319 assertions)
This commit is contained in:
+25
-1
@@ -11,10 +11,11 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Laravel\Scout\Searchable;
|
||||
|
||||
class Task extends Model
|
||||
{
|
||||
use HasFactory, LogsActivity, SoftDeletes;
|
||||
use HasFactory, LogsActivity, SoftDeletes, Searchable;
|
||||
|
||||
protected $fillable = [
|
||||
'project_id',
|
||||
@@ -328,4 +329,27 @@ class Task extends Model
|
||||
'critical' => 'Crítica',
|
||||
];
|
||||
}
|
||||
|
||||
public function toSearchableArray(): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'description' => $this->description,
|
||||
'project_id' => $this->project_id,
|
||||
'phase_id' => $this->phase_id,
|
||||
'parent_task_id' => $this->parent_task_id,
|
||||
'status' => $this->status,
|
||||
'priority' => $this->priority,
|
||||
'assigned_to' => $this->assigned_to,
|
||||
'due_date' => $this->due_date?->toDateString(),
|
||||
'start_date' => $this->start_date?->toDateString(),
|
||||
'completed_at' => $this->completed_at?->toDateTimeString(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getScoutKey(): string
|
||||
{
|
||||
return (string) $this->id;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user