Added: Create new refuel record
All checks were successful
Build and Deploy Zola Website / build_and_deploy (push) Successful in 13s
All checks were successful
Build and Deploy Zola Website / build_and_deploy (push) Successful in 13s
This commit is contained in:
@ -91,13 +91,16 @@ class Database {
|
||||
$refuelingTableQuery = "
|
||||
CREATE TABLE IF NOT EXISTS refueling_records (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id INT NOT NULL,
|
||||
vehicle_id INT NOT NULL,
|
||||
fuel_type ENUM('Diesel', 'Gasoline 95', 'Gasoline 98', 'Premium Diesel', 'Premium Gasoline 95', 'Premium Gasoline 98', 'Other') NOT NULL,
|
||||
liters DECIMAL(10, 2) NOT NULL,
|
||||
price_per_liter DECIMAL(10, 2) NOT NULL,
|
||||
total_price DECIMAL(10, 2) NOT NULL,
|
||||
note VARCHAR(150) NULL,
|
||||
liters DOUBLE(10, 2) NOT NULL,
|
||||
price_per_liter DOUBLE(10, 2) NOT NULL,
|
||||
total_price DOUBLE(10, 2) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (vehicle_id) REFERENCES vehicles(id) ON DELETE CASCADE
|
||||
FOREIGN KEY (vehicle_id) REFERENCES vehicles(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
";
|
||||
|
||||
|
@ -12,6 +12,15 @@ class Validator {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a field contains numbers
|
||||
*/
|
||||
public function number($field, $value, $message = null) {
|
||||
if(!is_numeric($value)) {
|
||||
$this->errors[$field] = $message ?? "$field must be an number";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a field meets minimum length
|
||||
*/
|
||||
@ -46,6 +55,10 @@ class Validator {
|
||||
return $this->errors;
|
||||
}
|
||||
|
||||
public function setErrors($errors) {
|
||||
$this->errors = $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if validation passed
|
||||
*/
|
||||
|
Reference in New Issue
Block a user