cc-codeconductor 0.4.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -95
- package/dist/cli/errors.d.ts +65 -0
- package/dist/core/compilation/compile-checker.d.ts +51 -0
- package/dist/core/config/codeconductor-config.d.ts +42 -0
- package/dist/core/config/config-loader.d.ts +11 -0
- package/dist/core/filesystem/credential-guard.d.ts +18 -0
- package/dist/core/goal/goal-planner.d.ts +8 -0
- package/dist/core/goal/goal-state.d.ts +15 -0
- package/dist/core/loop/git-stats.d.ts +13 -0
- package/dist/core/loop/loop-engine.d.ts +79 -0
- package/dist/core/memory/episodic-store.d.ts +6 -0
- package/dist/core/memory/operational-state.d.ts +6 -0
- package/dist/core/orchestrator/runtime-orchestrator.d.ts +25 -0
- package/dist/core/planner/product-planner.d.ts +18 -0
- package/dist/core/presets/package-paths.d.ts +4 -0
- package/dist/core/product-graph/graph-store.d.ts +11 -0
- package/dist/core/product-graph/paths.d.ts +18 -0
- package/dist/core/verification/verification-runner.d.ts +57 -0
- package/dist/domain/loop/loop-state.d.ts +74 -0
- package/dist/domain/product/entities.d.ts +11 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +23721 -15064
- package/dist/library.js +2595 -0
- package/dist/utils/result.d.ts +36 -0
- package/dist/validation/schemas.d.ts +3660 -0
- package/package.json +15 -2
- package/policy.yml +12 -11
- package/presets/agy/AGENTS.md +11 -5
- package/presets/agy/gates/pre-commit/GATE.md +136 -0
- package/presets/agy/skills/cc-fix/SKILL.md +2 -2
- package/presets/agy/skills/cc-tdd-cycle/SKILL.md +11 -0
- package/presets/agy/skills/evaluation/SKILL.md +6 -0
- package/presets/agy/skills/openspec/SKILL.md +32 -0
- package/presets/agy/workflows/cc-api-contract.md +12 -0
- package/presets/agy/workflows/cc-ask.md +55 -0
- package/presets/agy/workflows/cc-clarify.md +33 -0
- package/presets/agy/workflows/cc-council.md +31 -7
- package/presets/agy/workflows/cc-db-migration.md +22 -9
- package/presets/agy/workflows/cc-explore.md +37 -0
- package/presets/agy/workflows/cc-feature.md +41 -19
- package/presets/agy/workflows/cc-fix.md +50 -23
- package/presets/agy/workflows/cc-handoff.md +42 -0
- package/presets/agy/workflows/cc-iterative.md +128 -0
- package/presets/agy/workflows/cc-openspec.md +75 -0
- package/presets/agy/workflows/cc-pagespeed.md +12 -0
- package/presets/agy/workflows/cc-prototype.md +39 -0
- package/presets/agy/workflows/cc-refactor.md +12 -0
- package/presets/agy/workflows/cc-review.md +12 -0
- package/presets/agy/workflows/cc-scorecard.md +29 -0
- package/presets/agy/workflows/cc-tdd-cycle.md +24 -0
- package/presets/agy/workflows/cc-test-plan.md +12 -0
- package/presets/agy/workflows/cc-triage.md +35 -0
- package/presets/claude/CLAUDE.md +64 -0
- package/presets/claude/commands/cc/api-contract.md +12 -0
- package/presets/claude/commands/cc/ask.md +55 -0
- package/presets/claude/commands/cc/clarify.md +32 -0
- package/presets/claude/commands/cc/council.md +87 -0
- package/presets/claude/commands/cc/db-migration.md +22 -9
- package/presets/claude/commands/cc/explore.md +36 -0
- package/presets/claude/commands/cc/feature.md +49 -22
- package/presets/claude/commands/cc/fix.md +74 -20
- package/presets/claude/commands/cc/handoff.md +44 -0
- package/presets/claude/commands/cc/iterative.md +132 -0
- package/presets/claude/commands/cc/openspec.md +169 -0
- package/presets/claude/commands/cc/pagespeed.md +12 -0
- package/presets/claude/commands/cc/prototype.md +38 -0
- package/presets/claude/commands/cc/refactor.md +152 -1
- package/presets/claude/commands/cc/review.md +90 -17
- package/presets/claude/commands/cc/scorecard.md +77 -0
- package/presets/claude/commands/cc/tdd-cycle.md +53 -3
- package/presets/claude/commands/cc/test-plan.md +12 -0
- package/presets/claude/commands/cc/triage.md +34 -0
- package/presets/claude/gates/pre-commit/GATE.md +136 -0
- package/presets/claude/settings.json +8 -46
- package/presets/claude/skills/evaluation/SKILL.md +42 -0
- package/presets/claude/skills/openspec/SKILL.md +54 -0
- package/presets/codex/AGENTS.md +62 -5
- package/presets/codex/commands/cc-ask.md +55 -0
- package/presets/codex/gates/pre-commit/GATE.md +136 -0
- package/presets/cursor/.cursorignore +15 -0
- package/presets/cursor/AGENTS.md +504 -0
- package/presets/cursor/agents/architect.md +211 -0
- package/presets/cursor/agents/business-agent.md +44 -0
- package/presets/cursor/agents/complexity-auditor.md +76 -0
- package/presets/cursor/agents/continuous-architect.md +37 -0
- package/presets/cursor/agents/contract-builder.md +75 -0
- package/presets/cursor/agents/docs.md +181 -0
- package/presets/cursor/agents/goal-planner.md +71 -0
- package/presets/cursor/agents/impact-analyst.md +43 -0
- package/presets/cursor/agents/implementer.md +161 -0
- package/presets/cursor/agents/orchestrator.md +377 -0
- package/presets/cursor/agents/repo-explorer.md +100 -0
- package/presets/cursor/agents/reviewer.md +237 -0
- package/presets/cursor/agents/security-reviewer.md +113 -0
- package/presets/cursor/agents/task-coach.md +145 -0
- package/presets/cursor/agents/tester.md +241 -0
- package/presets/cursor/commands/cc/api-contract.md +70 -0
- package/presets/cursor/commands/cc/ask.md +55 -0
- package/presets/cursor/commands/cc/clarify.md +32 -0
- package/presets/cursor/commands/cc/council.md +87 -0
- package/presets/cursor/commands/cc/db-migration.md +71 -0
- package/presets/cursor/commands/cc/explore.md +36 -0
- package/presets/cursor/commands/cc/feature.md +137 -0
- package/presets/cursor/commands/cc/fix.md +148 -0
- package/presets/cursor/commands/cc/handoff.md +41 -0
- package/presets/cursor/commands/cc/iterative.md +133 -0
- package/presets/cursor/commands/cc/openspec.md +159 -0
- package/presets/cursor/commands/cc/pagespeed.md +115 -0
- package/presets/cursor/commands/cc/prototype.md +38 -0
- package/presets/cursor/commands/cc/refactor.md +160 -0
- package/presets/cursor/commands/cc/review.md +149 -0
- package/presets/cursor/commands/cc/scorecard.md +77 -0
- package/presets/cursor/commands/cc/tdd-cycle.md +250 -0
- package/presets/cursor/commands/cc/test-plan.md +150 -0
- package/presets/cursor/commands/cc/triage.md +34 -0
- package/presets/cursor/gates/pre-commit/GATE.md +136 -0
- package/presets/cursor/rules/behavioral-discipline.mdc +14 -0
- package/presets/cursor/rules/context-budget.mdc +12 -0
- package/presets/cursor/rules/orchestration.mdc +12 -0
- package/presets/cursor/rules/yagni-stdlib.mdc +11 -0
- package/presets/cursor/skills/android/SKILL.md +122 -0
- package/presets/cursor/skills/api-versioning/SKILL.md +394 -0
- package/presets/cursor/skills/astro/SKILL.md +322 -0
- package/presets/cursor/skills/auth-token-inspector/SKILL.md +33 -0
- package/presets/cursor/skills/code-review/SKILL.md +208 -0
- package/presets/cursor/skills/conductor-setup/SKILL.md +127 -0
- package/presets/cursor/skills/django-orm/SKILL.md +463 -0
- package/presets/cursor/skills/django-testing/SKILL.md +417 -0
- package/presets/cursor/skills/django-uv/SKILL.md +409 -0
- package/presets/cursor/skills/drizzle-schema-architect/SKILL.md +54 -0
- package/presets/cursor/skills/evaluation/SKILL.md +8 -0
- package/presets/cursor/skills/fastapi-pydantic-strict/SKILL.md +46 -0
- package/presets/cursor/skills/find-skills/SKILL.md +144 -0
- package/presets/cursor/skills/jpa-nplusone-detector/SKILL.md +49 -0
- package/presets/cursor/skills/jpa-postgres/SKILL.md +626 -0
- package/presets/cursor/skills/laravel-specialist/SKILL.md +267 -0
- package/presets/cursor/skills/laravel-specialist/references/eloquent.md +351 -0
- package/presets/cursor/skills/laravel-specialist/references/livewire.md +512 -0
- package/presets/cursor/skills/laravel-specialist/references/queues.md +423 -0
- package/presets/cursor/skills/laravel-specialist/references/routing.md +362 -0
- package/presets/cursor/skills/laravel-specialist/references/testing.md +522 -0
- package/presets/cursor/skills/livewire-alpine-bridge/SKILL.md +39 -0
- package/presets/cursor/skills/multi-agent-orchestration/README.md +144 -0
- package/presets/cursor/skills/multi-agent-orchestration/SKILL.md +579 -0
- package/presets/cursor/skills/multi-agent-orchestration/examples/framework_implementations.py +362 -0
- package/presets/cursor/skills/multi-agent-orchestration/examples/orchestration_patterns.py +411 -0
- package/presets/cursor/skills/multi-agent-orchestration/scripts/agent_communication.py +334 -0
- package/presets/cursor/skills/multi-agent-orchestration/scripts/benchmarking.py +341 -0
- package/presets/cursor/skills/multi-agent-orchestration/scripts/workflow_management.py +334 -0
- package/presets/cursor/skills/nextjs-typescript/SKILL.md +394 -0
- package/presets/cursor/skills/openspec/SKILL.md +52 -0
- package/presets/cursor/skills/pagespeed-insights/SKILL.md +445 -0
- package/presets/cursor/skills/pagespeed-insights/reference.md +50 -0
- package/presets/cursor/skills/pagespeed-perf/SKILL.md +281 -0
- package/presets/cursor/skills/php-pro/SKILL.md +210 -0
- package/presets/cursor/skills/php-pro/references/async-patterns.md +412 -0
- package/presets/cursor/skills/php-pro/references/laravel-patterns.md +377 -0
- package/presets/cursor/skills/php-pro/references/modern-php-features.md +323 -0
- package/presets/cursor/skills/php-pro/references/symfony-patterns.md +466 -0
- package/presets/cursor/skills/php-pro/references/testing-quality.md +466 -0
- package/presets/cursor/skills/python/SKILL.md +613 -0
- package/presets/cursor/skills/python-django-stack/SKILL.md +500 -0
- package/presets/cursor/skills/python-fastapi-stack/SKILL.md +464 -0
- package/presets/cursor/skills/security/SKILL.md +384 -0
- package/presets/cursor/skills/seo-analytics-injector/SKILL.md +44 -0
- package/presets/cursor/skills/spring-auth-auditor/SKILL.md +33 -0
- package/presets/cursor/skills/spring-boot-feature/SKILL.md +566 -0
- package/presets/cursor/skills/spring-boot-kotlin/SKILL.md +408 -0
- package/presets/cursor/skills/spring-boot-testing-strategy/SKILL.md +479 -0
- package/presets/cursor/skills/sqlalchemy/SKILL.md +473 -0
- package/presets/cursor/skills/tailwind-responsive-auditor/SKILL.md +32 -0
- package/presets/cursor/skills/tdd-mutation-tester/SKILL.md +28 -0
- package/presets/cursor/skills/testing-tdd/SKILL.md +592 -0
- package/presets/cursor/skills/workflow-orchestration-patterns/SKILL.md +98 -0
- package/presets/cursor/skills/workflow-orchestration-patterns/references/details.md +223 -0
- package/presets/opencode/agents/architect.md +22 -2
- package/presets/opencode/agents/complexity-auditor.md +16 -0
- package/presets/opencode/agents/contract-builder.md +109 -0
- package/presets/opencode/agents/devil.md +158 -0
- package/presets/opencode/agents/docs.md +19 -2
- package/presets/opencode/agents/goal-planner.md +112 -0
- package/presets/opencode/agents/implementer.md +39 -2
- package/presets/opencode/agents/orchestrator.md +124 -19
- package/presets/opencode/agents/planner.md +61 -0
- package/presets/opencode/agents/repo-explorer.md +15 -0
- package/presets/opencode/agents/reviewer.md +53 -2
- package/presets/opencode/agents/security-reviewer.md +159 -0
- package/presets/opencode/agents/task-coach.md +69 -2
- package/presets/opencode/agents/tester.md +18 -2
- package/presets/opencode/commands/cc-api-contract.md +12 -0
- package/presets/opencode/commands/cc-ask.md +55 -0
- package/presets/opencode/commands/cc-clarify.md +31 -0
- package/presets/opencode/commands/cc-council.md +87 -0
- package/presets/opencode/commands/cc-db-migration.md +22 -9
- package/presets/opencode/commands/cc-explore.md +35 -0
- package/presets/opencode/commands/cc-feature.md +41 -19
- package/presets/opencode/commands/cc-fix.md +50 -23
- package/presets/opencode/commands/cc-handoff.md +40 -0
- package/presets/opencode/commands/cc-iterative.md +127 -0
- package/presets/opencode/commands/cc-openspec.md +74 -0
- package/presets/opencode/commands/cc-pagespeed.md +12 -0
- package/presets/opencode/commands/cc-prototype.md +37 -0
- package/presets/opencode/commands/cc-refactor.md +12 -0
- package/presets/opencode/commands/cc-review.md +12 -0
- package/presets/opencode/commands/cc-scorecard.md +28 -0
- package/presets/opencode/commands/cc-tdd-cycle.md +24 -0
- package/presets/opencode/commands/cc-test-plan.md +12 -0
- package/presets/opencode/commands/cc-triage.md +33 -0
- package/presets/opencode/gates/pre-commit/GATE.md +136 -0
- package/presets/opencode/prompts/v0.1.0/DEPRECATED.md +11 -0
- package/presets/opencode/prompts/v0.2.0/DEPRECATED.md +11 -0
- package/presets/opencode/prompts/v0.3.0/DEPRECATED.md +11 -0
- package/presets/opencode/prompts/v0.4.0/DEPRECATED.md +11 -0
- package/presets/opencode/prompts/v0.5.0/architect.md +222 -0
- package/presets/opencode/prompts/v0.5.0/complexity-auditor.md +91 -0
- package/presets/opencode/prompts/v0.5.0/contract-builder.md +84 -0
- package/presets/opencode/prompts/v0.5.0/docs.md +190 -0
- package/presets/opencode/prompts/v0.5.0/goal-planner.md +80 -0
- package/presets/opencode/prompts/v0.5.0/implementer.md +171 -0
- package/presets/opencode/prompts/v0.5.0/orchestrator.md +388 -0
- package/presets/opencode/prompts/v0.5.0/repo-explorer.md +111 -0
- package/presets/opencode/prompts/v0.5.0/reviewer.md +248 -0
- package/presets/opencode/prompts/v0.5.0/security-reviewer.md +123 -0
- package/presets/opencode/prompts/v0.5.0/task-coach.md +156 -0
- package/presets/opencode/prompts/v0.5.0/tester.md +252 -0
- package/presets/opencode/prompts/v0.6.0/implementer.md +35 -0
- package/presets/opencode/prompts/v0.6.0/planner.md +36 -0
- package/presets/opencode/prompts/v0.6.0/reviewer.md +40 -0
- package/presets/opencode/prompts/v1.0.0/README.md +47 -0
- package/presets/opencode/prompts/v1.0.0/architect.md +259 -0
- package/presets/opencode/prompts/v1.0.0/complexity-auditor.md +116 -0
- package/presets/opencode/prompts/v1.0.0/contract-builder.md +120 -0
- package/presets/opencode/prompts/v1.0.0/devil.md +169 -0
- package/presets/opencode/prompts/v1.0.0/docs.md +229 -0
- package/presets/opencode/prompts/v1.0.0/goal-planner.md +123 -0
- package/presets/opencode/prompts/v1.0.0/implementer.md +228 -0
- package/presets/opencode/prompts/v1.0.0/orchestrator.md +474 -0
- package/presets/opencode/prompts/v1.0.0/planner.md +72 -0
- package/presets/opencode/prompts/v1.0.0/repo-explorer.md +147 -0
- package/presets/opencode/prompts/v1.0.0/reviewer.md +295 -0
- package/presets/opencode/prompts/v1.0.0/security-reviewer.md +170 -0
- package/presets/opencode/prompts/v1.0.0/task-coach.md +235 -0
- package/presets/opencode/prompts/v1.0.0/tester.md +298 -0
- package/presets/opencode/skills/evaluation/SKILL.md +6 -0
- package/presets/opencode/skills/openspec/SKILL.md +50 -0
- package/presets/seo-hotel/settings.json +0 -17
- package/presets/templates/BACKLOG.md +33 -0
- package/presets/templates/execution-profile.yml +6 -0
- package/presets/templates/model-comparison.md +11 -0
- package/presets/templates/regression-checklist.yml +10 -0
- package/src/presets/manifests/agy.yml +2 -2
- package/src/presets/manifests/claude.yml +2 -2
- package/src/presets/manifests/codex.yml +2 -2
- package/src/presets/manifests/cursor.yml +19 -3
- package/src/presets/manifests/gemini.yml +2 -2
- package/src/presets/manifests/opencode.yml +2 -2
- package/src/presets/models/agy.yml +97 -49
- package/src/presets/models/claude.yml +83 -39
- package/src/presets/models/codex.yml +83 -40
- package/src/presets/models/cursor.yml +83 -39
- package/src/presets/models/gemini.yml +83 -39
- package/src/presets/models/opencode.yml +78 -34
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
# Livewire Components
|
|
2
|
+
|
|
3
|
+
## Component Patterns
|
|
4
|
+
|
|
5
|
+
```php
|
|
6
|
+
namespace App\Http\Livewire;
|
|
7
|
+
|
|
8
|
+
use Livewire\Component;
|
|
9
|
+
use Livewire\WithPagination;
|
|
10
|
+
use Livewire\WithFileUploads;
|
|
11
|
+
use App\Models\Post;
|
|
12
|
+
|
|
13
|
+
class PostList extends Component
|
|
14
|
+
{
|
|
15
|
+
use WithPagination, WithFileUploads;
|
|
16
|
+
|
|
17
|
+
public string $search = '';
|
|
18
|
+
public string $sortBy = 'created_at';
|
|
19
|
+
public string $sortDirection = 'desc';
|
|
20
|
+
public ?int $categoryId = null;
|
|
21
|
+
|
|
22
|
+
protected $queryString = [
|
|
23
|
+
'search' => ['except' => ''],
|
|
24
|
+
'sortBy' => ['except' => 'created_at'],
|
|
25
|
+
'categoryId' => ['except' => null],
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
public function updatingSearch(): void
|
|
29
|
+
{
|
|
30
|
+
$this->resetPage();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public function sortBy(string $field): void
|
|
34
|
+
{
|
|
35
|
+
if ($this->sortBy === $field) {
|
|
36
|
+
$this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc';
|
|
37
|
+
} else {
|
|
38
|
+
$this->sortBy = $field;
|
|
39
|
+
$this->sortDirection = 'asc';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public function render()
|
|
44
|
+
{
|
|
45
|
+
return view('livewire.post-list', [
|
|
46
|
+
'posts' => Post::query()
|
|
47
|
+
->when($this->search, fn($q) => $q->where('title', 'like', "%{$this->search}%"))
|
|
48
|
+
->when($this->categoryId, fn($q) => $q->where('category_id', $this->categoryId))
|
|
49
|
+
->orderBy($this->sortBy, $this->sortDirection)
|
|
50
|
+
->paginate(10),
|
|
51
|
+
]);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Blade Template
|
|
57
|
+
|
|
58
|
+
```blade
|
|
59
|
+
<div>
|
|
60
|
+
{{-- Search --}}
|
|
61
|
+
<input
|
|
62
|
+
type="text"
|
|
63
|
+
wire:model.debounce.300ms="search"
|
|
64
|
+
placeholder="Search posts..."
|
|
65
|
+
class="form-input"
|
|
66
|
+
>
|
|
67
|
+
|
|
68
|
+
{{-- Filter by category --}}
|
|
69
|
+
<select wire:model="categoryId">
|
|
70
|
+
<option value="">All Categories</option>
|
|
71
|
+
@foreach($categories as $category)
|
|
72
|
+
<option value="{{ $category->id }}">{{ $category->name }}</option>
|
|
73
|
+
@endforeach
|
|
74
|
+
</select>
|
|
75
|
+
|
|
76
|
+
{{-- Sortable table --}}
|
|
77
|
+
<table>
|
|
78
|
+
<thead>
|
|
79
|
+
<tr>
|
|
80
|
+
<th wire:click="sortBy('title')" style="cursor: pointer">
|
|
81
|
+
Title
|
|
82
|
+
@if($sortBy === 'title')
|
|
83
|
+
<span>{{ $sortDirection === 'asc' ? '↑' : '↓' }}</span>
|
|
84
|
+
@endif
|
|
85
|
+
</th>
|
|
86
|
+
<th wire:click="sortBy('created_at')" style="cursor: pointer">
|
|
87
|
+
Date
|
|
88
|
+
@if($sortBy === 'created_at')
|
|
89
|
+
<span>{{ $sortDirection === 'asc' ? '↑' : '↓' }}</span>
|
|
90
|
+
@endif
|
|
91
|
+
</th>
|
|
92
|
+
</tr>
|
|
93
|
+
</thead>
|
|
94
|
+
<tbody>
|
|
95
|
+
@foreach($posts as $post)
|
|
96
|
+
<tr>
|
|
97
|
+
<td>{{ $post->title }}</td>
|
|
98
|
+
<td>{{ $post->created_at->diffForHumans() }}</td>
|
|
99
|
+
</tr>
|
|
100
|
+
@endforeach
|
|
101
|
+
</tbody>
|
|
102
|
+
</table>
|
|
103
|
+
|
|
104
|
+
{{-- Pagination --}}
|
|
105
|
+
{{ $posts->links() }}
|
|
106
|
+
|
|
107
|
+
{{-- Loading states --}}
|
|
108
|
+
<div wire:loading wire:target="search">
|
|
109
|
+
Searching...
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Form Component
|
|
115
|
+
|
|
116
|
+
```php
|
|
117
|
+
namespace App\Http\Livewire;
|
|
118
|
+
|
|
119
|
+
use Livewire\Component;
|
|
120
|
+
use App\Models\Post;
|
|
121
|
+
|
|
122
|
+
class PostForm extends Component
|
|
123
|
+
{
|
|
124
|
+
public ?Post $post = null;
|
|
125
|
+
public string $title = '';
|
|
126
|
+
public string $content = '';
|
|
127
|
+
public array $tags = [];
|
|
128
|
+
public $image;
|
|
129
|
+
|
|
130
|
+
protected function rules(): array
|
|
131
|
+
{
|
|
132
|
+
return [
|
|
133
|
+
'title' => 'required|min:3|max:255',
|
|
134
|
+
'content' => 'required|min:10',
|
|
135
|
+
'tags' => 'array|max:5',
|
|
136
|
+
'tags.*' => 'exists:tags,id',
|
|
137
|
+
'image' => 'nullable|image|max:2048',
|
|
138
|
+
];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
public function mount(?Post $post = null): void
|
|
142
|
+
{
|
|
143
|
+
if ($post) {
|
|
144
|
+
$this->post = $post;
|
|
145
|
+
$this->title = $post->title;
|
|
146
|
+
$this->content = $post->content;
|
|
147
|
+
$this->tags = $post->tags->pluck('id')->toArray();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
public function updated($propertyName): void
|
|
152
|
+
{
|
|
153
|
+
$this->validateOnly($propertyName);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
public function save(): void
|
|
157
|
+
{
|
|
158
|
+
$validated = $this->validate();
|
|
159
|
+
|
|
160
|
+
if ($this->post) {
|
|
161
|
+
$this->post->update($validated);
|
|
162
|
+
$message = 'Post updated successfully!';
|
|
163
|
+
} else {
|
|
164
|
+
$this->post = Post::create($validated);
|
|
165
|
+
$message = 'Post created successfully!';
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if ($this->image) {
|
|
169
|
+
$this->post->update([
|
|
170
|
+
'image_path' => $this->image->store('posts', 'public'),
|
|
171
|
+
]);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
$this->post->tags()->sync($this->tags);
|
|
175
|
+
|
|
176
|
+
session()->flash('message', $message);
|
|
177
|
+
$this->redirect(route('posts.show', $this->post));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
public function render()
|
|
181
|
+
{
|
|
182
|
+
return view('livewire.post-form');
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Form Template
|
|
188
|
+
|
|
189
|
+
```blade
|
|
190
|
+
<form wire:submit.prevent="save">
|
|
191
|
+
{{-- Title --}}
|
|
192
|
+
<div>
|
|
193
|
+
<label for="title">Title</label>
|
|
194
|
+
<input
|
|
195
|
+
type="text"
|
|
196
|
+
wire:model.defer="title"
|
|
197
|
+
id="title"
|
|
198
|
+
class="@error('title') border-red-500 @enderror"
|
|
199
|
+
>
|
|
200
|
+
@error('title')
|
|
201
|
+
<span class="text-red-500">{{ $message }}</span>
|
|
202
|
+
@enderror
|
|
203
|
+
</div>
|
|
204
|
+
|
|
205
|
+
{{-- Content --}}
|
|
206
|
+
<div>
|
|
207
|
+
<label for="content">Content</label>
|
|
208
|
+
<textarea
|
|
209
|
+
wire:model.defer="content"
|
|
210
|
+
id="content"
|
|
211
|
+
class="@error('content') border-red-500 @enderror"
|
|
212
|
+
></textarea>
|
|
213
|
+
@error('content')
|
|
214
|
+
<span class="text-red-500">{{ $message }}</span>
|
|
215
|
+
@enderror
|
|
216
|
+
</div>
|
|
217
|
+
|
|
218
|
+
{{-- Tags --}}
|
|
219
|
+
<div>
|
|
220
|
+
<label>Tags</label>
|
|
221
|
+
@foreach($availableTags as $tag)
|
|
222
|
+
<label>
|
|
223
|
+
<input
|
|
224
|
+
type="checkbox"
|
|
225
|
+
wire:model="tags"
|
|
226
|
+
value="{{ $tag->id }}"
|
|
227
|
+
>
|
|
228
|
+
{{ $tag->name }}
|
|
229
|
+
</label>
|
|
230
|
+
@endforeach
|
|
231
|
+
@error('tags')
|
|
232
|
+
<span class="text-red-500">{{ $message }}</span>
|
|
233
|
+
@enderror
|
|
234
|
+
</div>
|
|
235
|
+
|
|
236
|
+
{{-- File Upload --}}
|
|
237
|
+
<div>
|
|
238
|
+
<label>Image</label>
|
|
239
|
+
<input type="file" wire:model="image">
|
|
240
|
+
|
|
241
|
+
@error('image')
|
|
242
|
+
<span class="text-red-500">{{ $message }}</span>
|
|
243
|
+
@enderror
|
|
244
|
+
|
|
245
|
+
{{-- Upload progress --}}
|
|
246
|
+
<div wire:loading wire:target="image">
|
|
247
|
+
Uploading...
|
|
248
|
+
</div>
|
|
249
|
+
|
|
250
|
+
{{-- Preview --}}
|
|
251
|
+
@if ($image)
|
|
252
|
+
<img src="{{ $image->temporaryUrl() }}" alt="Preview">
|
|
253
|
+
@endif
|
|
254
|
+
</div>
|
|
255
|
+
|
|
256
|
+
{{-- Submit --}}
|
|
257
|
+
<button type="submit" wire:loading.attr="disabled">
|
|
258
|
+
<span wire:loading.remove>Save</span>
|
|
259
|
+
<span wire:loading>Saving...</span>
|
|
260
|
+
</button>
|
|
261
|
+
</form>
|
|
262
|
+
|
|
263
|
+
@if (session()->has('message'))
|
|
264
|
+
<div class="alert alert-success">
|
|
265
|
+
{{ session('message') }}
|
|
266
|
+
</div>
|
|
267
|
+
@endif
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## Real-time Validation
|
|
271
|
+
|
|
272
|
+
```php
|
|
273
|
+
class PostForm extends Component
|
|
274
|
+
{
|
|
275
|
+
public string $title = '';
|
|
276
|
+
|
|
277
|
+
protected $rules = [
|
|
278
|
+
'title' => 'required|min:3|unique:posts,title',
|
|
279
|
+
];
|
|
280
|
+
|
|
281
|
+
// Real-time validation
|
|
282
|
+
public function updated($propertyName): void
|
|
283
|
+
{
|
|
284
|
+
$this->validateOnly($propertyName);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Custom validation messages
|
|
288
|
+
protected $messages = [
|
|
289
|
+
'title.required' => 'The post title is required.',
|
|
290
|
+
'title.min' => 'The title must be at least 3 characters.',
|
|
291
|
+
'title.unique' => 'This title is already taken.',
|
|
292
|
+
];
|
|
293
|
+
|
|
294
|
+
// Custom attribute names
|
|
295
|
+
protected $validationAttributes = [
|
|
296
|
+
'title' => 'post title',
|
|
297
|
+
];
|
|
298
|
+
}
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
## Events
|
|
302
|
+
|
|
303
|
+
```php
|
|
304
|
+
// Emit event
|
|
305
|
+
class PostList extends Component
|
|
306
|
+
{
|
|
307
|
+
public function deletePost($postId): void
|
|
308
|
+
{
|
|
309
|
+
Post::find($postId)->delete();
|
|
310
|
+
|
|
311
|
+
$this->emit('postDeleted', $postId);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Listen to event
|
|
316
|
+
class PostStats extends Component
|
|
317
|
+
{
|
|
318
|
+
protected $listeners = ['postDeleted' => 'updateStats'];
|
|
319
|
+
|
|
320
|
+
public function updateStats($postId): void
|
|
321
|
+
{
|
|
322
|
+
// Update statistics
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Emit to specific component
|
|
327
|
+
$this->emitTo('post-stats', 'refresh');
|
|
328
|
+
|
|
329
|
+
// Emit to parent/children
|
|
330
|
+
$this->emitUp('saved');
|
|
331
|
+
$this->emitSelf('refresh');
|
|
332
|
+
|
|
333
|
+
// Browser events
|
|
334
|
+
$this->dispatchBrowserEvent('post-saved', ['id' => $post->id]);
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
## Listen to Browser Events
|
|
338
|
+
|
|
339
|
+
```blade
|
|
340
|
+
<div
|
|
341
|
+
x-data
|
|
342
|
+
@post-saved.window="alert('Post saved!')"
|
|
343
|
+
>
|
|
344
|
+
<!-- content -->
|
|
345
|
+
</div>
|
|
346
|
+
|
|
347
|
+
<script>
|
|
348
|
+
window.addEventListener('post-saved', event => {
|
|
349
|
+
console.log('Post ID:', event.detail.id);
|
|
350
|
+
});
|
|
351
|
+
</script>
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
## Polling
|
|
355
|
+
|
|
356
|
+
```blade
|
|
357
|
+
{{-- Poll every 2 seconds --}}
|
|
358
|
+
<div wire:poll.2s>
|
|
359
|
+
Current time: {{ now() }}
|
|
360
|
+
</div>
|
|
361
|
+
|
|
362
|
+
{{-- Poll specific action --}}
|
|
363
|
+
<div wire:poll.5s="checkStatus">
|
|
364
|
+
Status: {{ $status }}
|
|
365
|
+
</div>
|
|
366
|
+
|
|
367
|
+
{{-- Keep polling until condition --}}
|
|
368
|
+
<div wire:poll.keep-alive.2s>
|
|
369
|
+
<!-- content -->
|
|
370
|
+
</div>
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
## Loading States
|
|
374
|
+
|
|
375
|
+
```blade
|
|
376
|
+
{{-- Basic loading state --}}
|
|
377
|
+
<div wire:loading>
|
|
378
|
+
Loading...
|
|
379
|
+
</div>
|
|
380
|
+
|
|
381
|
+
{{-- Target specific action --}}
|
|
382
|
+
<div wire:loading wire:target="save">
|
|
383
|
+
Saving...
|
|
384
|
+
</div>
|
|
385
|
+
|
|
386
|
+
{{-- Hide element while loading --}}
|
|
387
|
+
<div wire:loading.remove>
|
|
388
|
+
Content (hidden during load)
|
|
389
|
+
</div>
|
|
390
|
+
|
|
391
|
+
{{-- Delay loading indicator --}}
|
|
392
|
+
<div wire:loading.delay>
|
|
393
|
+
This appears after 200ms
|
|
394
|
+
</div>
|
|
395
|
+
|
|
396
|
+
{{-- Custom delay --}}
|
|
397
|
+
<div wire:loading.delay.longest>
|
|
398
|
+
This appears after 1s
|
|
399
|
+
</div>
|
|
400
|
+
|
|
401
|
+
{{-- Loading classes --}}
|
|
402
|
+
<button
|
|
403
|
+
wire:click="save"
|
|
404
|
+
wire:loading.class="opacity-50"
|
|
405
|
+
wire:loading.class.remove="bg-blue-500"
|
|
406
|
+
>
|
|
407
|
+
Save
|
|
408
|
+
</button>
|
|
409
|
+
|
|
410
|
+
{{-- Loading attributes --}}
|
|
411
|
+
<button
|
|
412
|
+
wire:click="save"
|
|
413
|
+
wire:loading.attr="disabled"
|
|
414
|
+
>
|
|
415
|
+
Save
|
|
416
|
+
</button>
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
## Traits
|
|
420
|
+
|
|
421
|
+
```php
|
|
422
|
+
// Pagination
|
|
423
|
+
use Livewire\WithPagination;
|
|
424
|
+
|
|
425
|
+
class PostList extends Component
|
|
426
|
+
{
|
|
427
|
+
use WithPagination;
|
|
428
|
+
|
|
429
|
+
public function render()
|
|
430
|
+
{
|
|
431
|
+
return view('livewire.post-list', [
|
|
432
|
+
'posts' => Post::paginate(10),
|
|
433
|
+
]);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// File uploads
|
|
438
|
+
use Livewire\WithFileUploads;
|
|
439
|
+
|
|
440
|
+
class UploadPhoto extends Component
|
|
441
|
+
{
|
|
442
|
+
use WithFileUploads;
|
|
443
|
+
|
|
444
|
+
public $photo;
|
|
445
|
+
|
|
446
|
+
public function save(): void
|
|
447
|
+
{
|
|
448
|
+
$this->validate([
|
|
449
|
+
'photo' => 'image|max:1024',
|
|
450
|
+
]);
|
|
451
|
+
|
|
452
|
+
$this->photo->store('photos');
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
## Authorization
|
|
458
|
+
|
|
459
|
+
```php
|
|
460
|
+
class PostForm extends Component
|
|
461
|
+
{
|
|
462
|
+
public Post $post;
|
|
463
|
+
|
|
464
|
+
public function mount(Post $post): void
|
|
465
|
+
{
|
|
466
|
+
$this->authorize('update', $post);
|
|
467
|
+
$this->post = $post;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
public function save(): void
|
|
471
|
+
{
|
|
472
|
+
$this->authorize('update', $this->post);
|
|
473
|
+
// Save logic
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
## Performance Tips
|
|
479
|
+
|
|
480
|
+
1. **Use wire:model.defer** - Batch updates on form submit
|
|
481
|
+
2. **Lazy load components** - Use wire:init for heavy operations
|
|
482
|
+
3. **Cache computed properties** - Use #[Computed] attribute
|
|
483
|
+
4. **Disable polling when hidden** - Use wire:poll.visible
|
|
484
|
+
5. **Optimize queries** - Eager load relationships
|
|
485
|
+
6. **Use wire:key** - Prevent re-rendering entire lists
|
|
486
|
+
7. **Debounce input** - Use wire:model.debounce
|
|
487
|
+
8. **Use pagination** - Don't load all records at once
|
|
488
|
+
|
|
489
|
+
```php
|
|
490
|
+
use Livewire\Attributes\Computed;
|
|
491
|
+
|
|
492
|
+
class PostList extends Component
|
|
493
|
+
{
|
|
494
|
+
#[Computed]
|
|
495
|
+
public function posts()
|
|
496
|
+
{
|
|
497
|
+
return Post::with('user')->paginate(10);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
public function render()
|
|
501
|
+
{
|
|
502
|
+
return view('livewire.post-list');
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
```blade
|
|
508
|
+
{{-- Access computed property --}}
|
|
509
|
+
@foreach($this->posts as $post)
|
|
510
|
+
<!-- content -->
|
|
511
|
+
@endforeach
|
|
512
|
+
```
|