<?php

namespace App\Models;

use PDO;
use Config\Database;

class Attachment extends BaseModel
{
    protected static $table = 'attachments';

    public $id;
    public $location_id;
    public $file_name;
    public $file_path;
    public $created_at;
    public $deleted_at;

    public function __construct($data = [])
    {
        parent::__construct($data);
    }

    public function save()
    {
        $db = Database::getConnection();

        $query = "INSERT INTO attachments (location_id, file_name, file_path, deleted_at) VALUES (:location_id, :file_name, :file_path, :deleted_at)";
        $stmt = $db->prepare($query);

        $stmt->bindParam(':location_id', $this->location_id);
        $stmt->bindParam(':file_name', $this->file_name);
        $stmt->bindParam(':file_path', $this->file_path);
        $stmt->bindParam(':deleted_at', $this->deleted_at);

        return $stmt->execute();
    }
}
