<?php
class Setting extends Database {

    public function getSettings() {
        $this->query("SELECT * FROM settings WHERE id = 1");
        return $this->single();
    }

    public function updateSettings($data) {
        $this->query("UPDATE settings SET 
            site_title=:site_title, 
            phone=:phone, 
            email=:email, 
            address=:address, 
            about_text=:about_text,
            about_subtitle=:about_subtitle, 
            about_heading=:about_heading,
            stat_years=:stat_years,
            stat_customers=:stat_customers,
            stat_sales=:stat_sales,
            stat_awards=:stat_awards,
            facebook=:facebook, 
            instagram=:instagram, 
            twitter=:twitter,
            adv1_title=:adv1_title,
            adv1_text=:adv1_text,
            adv2_title=:adv2_title,
            adv2_text=:adv2_text,
            adv3_title=:adv3_title,
            adv3_text=:adv3_text
            WHERE id=1");

        $this->bind(':site_title', $data['site_title']);
        $this->bind(':phone', $data['phone']);
        $this->bind(':email', $data['email']);
        $this->bind(':address', $data['address']);
        $this->bind(':about_text', $data['about_text']);

        $this->bind(':about_subtitle', $data['about_subtitle']);
        $this->bind(':about_heading', $data['about_heading']);
        $this->bind(':stat_years', $data['stat_years']);
        $this->bind(':stat_customers', $data['stat_customers']);
        $this->bind(':stat_sales', $data['stat_sales']);
        $this->bind(':stat_awards', $data['stat_awards']);

        $this->bind(':facebook', $data['facebook']);
        $this->bind(':instagram', $data['instagram']);
        $this->bind(':twitter', $data['twitter']);

        $this->bind(':adv1_title', $data['adv1_title']);
        $this->bind(':adv1_text', $data['adv1_text']);
        $this->bind(':adv2_title', $data['adv2_title']);
        $this->bind(':adv2_text', $data['adv2_text']);
        $this->bind(':adv3_title', $data['adv3_title']);
        $this->bind(':adv3_text', $data['adv3_text']);

        return $this->execute();
    }

    public function updateLogo($path) {
        $this->query("UPDATE settings SET site_logo = :site_logo WHERE id = 1");
        $this->bind(':site_logo', $path);
        return $this->execute();
    }
}
