🚀 مُصادَق: تحديث برمجي جديد 2026-05-03 02:16
This commit is contained in:
@@ -25,8 +25,8 @@ final class Request
|
||||
$this->queryParams = $_GET;
|
||||
$this->files = $_FILES;
|
||||
|
||||
$contentType = $this->getHeader('Content-Type');
|
||||
if ($contentType && str_contains($contentType, 'application/json')) {
|
||||
$contentType = $this->getHeader('Content-Type') ?? $_SERVER['CONTENT_TYPE'] ?? '';
|
||||
if ($contentType && str_contains(strtolower($contentType), 'application/json')) {
|
||||
$this->body = json_decode(file_get_contents('php://input'), true) ?? [];
|
||||
} else {
|
||||
$this->body = $_POST;
|
||||
|
||||
@@ -16,6 +16,15 @@ final class InvoiceController
|
||||
private readonly FileStorageService $storage
|
||||
) {}
|
||||
|
||||
public function list(Request $request): void
|
||||
{
|
||||
$invoices = $this->invoiceModel->findByTenant($request->tenantId);
|
||||
Response::json([
|
||||
'success' => true,
|
||||
'data' => $invoices
|
||||
]);
|
||||
}
|
||||
|
||||
public function upload(Request $request): void
|
||||
{
|
||||
$files = $request->getFiles();
|
||||
|
||||
@@ -10,6 +10,13 @@ final class InvoiceModel extends BaseModel
|
||||
{
|
||||
protected string $table = 'invoices';
|
||||
|
||||
public function findByTenant(string $tenantId): array
|
||||
{
|
||||
$stmt = $this->db()->prepare("SELECT * FROM {$this->table} WHERE tenant_id = ? AND deleted_at IS NULL ORDER BY created_at DESC");
|
||||
$stmt->execute([$tenantId]);
|
||||
return $stmt->fetchAll();
|
||||
}
|
||||
|
||||
public function findByStatus(string $status, ?string $tenantId = null): array
|
||||
{
|
||||
$sql = "SELECT * FROM {$this->table} WHERE status = ? AND deleted_at IS NULL";
|
||||
|
||||
Reference in New Issue
Block a user