<?php
declare(strict_types=1);

namespace App\Core\Http;

trait ToggleableRepositoryTrait
{
    public function toggleActive(string $table, int $id, string $column = 'is_active'): bool
    {
        $statement = $this->pdo->prepare(
            'UPDATE ' . $table . ' SET ' . $column . ' = NOT ' . $column . ' WHERE id = :id'
        );

        return $statement->execute(['id' => $id]);
    }
}
