<?php


namespace App\Models;

use \App\Maps\Model;

/**
*
*/
class Transactions extends Model
{

    public static function read(int $userid)
    {

    	global $db;

        $query = "SELECT * FROM transactions WHERE user_id = :userid ;";
        $parameters = [
            'userid' => $userid
        ];

        return $db->all($query, $parameters);

    }


    public static function create($userid, $description, $type, $amount)
    {

        global $db;

        $query = "
            INSERT INTO transactions (user_id, trans_description, trans_type, trans_amount) 
            VALUES (:userid, :description, :type, :amount) 
            ;
        ";
        $parameters = [
            'userid' => $userid,
            'description' => $description,
            'type' => $type,
            'amount' => $amount
        ];

        return $db->count($query, $parameters);

    }





}
