Files
project-manager/src/Http/Controllers/ProjectScopedController.php
T
aneurinandClaude Sonnet 5 fb59a54938 Drop the unused project description field entirely
It never got a UI home on the frontend -- removed from ProjectView a
few sessions back and never restored anywhere -- so it was a fully
live field (validated, stored, returned by the API, covered by tests)
with no consumer.

- Migration 011: ALTER TABLE projects DROP COLUMN description.
- ProjectRepository: description dropped from ProjectRow, SELECT,
  create() and update() -- update() is now just a rename (string, not
  a $fields array; there was never more than one editable field once
  this left).
- ProjectController: store()/update() no longer accept or validate
  it; update() drops the "provide at least one of title, description"
  branch, since title is unconditionally the only field now.
- Frontend Project type, root README's API docs and curl example.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-05 01:25:53 +01:00

48 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Controllers;
use App\Exception\ApiException;
use App\Repository\ProjectRepository;
use Psr\Http\Message\ServerRequestInterface as Request;
/**
* Shared helper for controllers whose routes are nested under
* /projects/{projectId}: looking up the project named in the route, 404-ing
* if it's missing or not owned by the caller.
*/
abstract class ProjectScopedController extends Controller
{
public function __construct(protected readonly ProjectRepository $projects)
{
}
/**
* The project named in the route, or 404 if it is missing or not owned
* by the authenticated user.
*
* @param array<string, string> $args
* @return array{id: int, owner_id: int, title: string, card_count: int, completed_count: int, created_at: string, updated_at: string}
*/
protected function requireOwnedProject(Request $request, array $args): array
{
$project = $this->projects->findOwnedBy((int) $args['projectId'], $this->user($request)['id']);
if ($project === null) {
throw new ApiException('Project not found.', 404);
}
return $project;
}
/**
* @param array<string, string> $args
*/
protected function requireOwnedProjectId(Request $request, array $args): int
{
return $this->requireOwnedProject($request, $args)['id'];
}
}