<?php

namespace App\Models;

use App\Core\Model;

class Photo extends Model
{
    protected $table = 'photos';
    protected $primaryKey = 'id';

    public function getByAlbum($albumId)
    {
        $stmt = $this->db->prepare("SELECT p.*, u.name as uploaded_by_name FROM {$this->table} p LEFT JOIN users u ON p.user_id = u.id WHERE p.album_id = ? ORDER BY p.sort_order ASC, p.created_at ASC");
        $stmt->execute([$albumId]);
        return $stmt->fetchAll(\PDO::FETCH_OBJ);
    }
}
