sasilen / sensors
Sensors plugin for CakePHP 4
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:cakephp-plugin
Requires
- cakephp/cakephp: ~4.1.0
- muffin/tags: 2.0.0-beta
- nnnick/chartjs: *
Requires (Dev)
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2024-11-29 05:20:54 UTC
README
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer config repositories.sensors git https://github.com/sasilen/cakephp-plugin-sensors.git
composer require sasilen/sensors
Configuration
Load required modules with routes
./bin/cake plugin load Sasilen/Sensors
Migrate database schema
./bin/cake migrations migrate -p Sensors
Add templates (main app)
# /src/View/AppView.php
public function initialize(): void
{
parent::initialize();
$this->loadHelper('CakeDC/Users.AuthLink');
$this->loadHelper('Paginator', ['templates' => 'templates-paginator']);
$this->loadHelper('Form', ['templates' => 'templates-form']);
}
Triggers
If you want to update sensor_id automatically from the sensors list when sensor_value is inserted you can create these two trigger
CREATE TRIGGER sensor_values_sensor_id_updater
BEFORE UPDATE ON sensor_values
FOR EACH ROW
SET new.sensor_id = (select id from sensors where name=new.name);
CREATE TRIGGER sensor_values_sensor_id_inserter
BEFORE INSERT ON sensor_values
FOR EACH ROW
SET new.sensor_id = (select id from sensors where name=new.name);
FIX missing:
UPDATE sensor_values SET sensor_values.sensor_id = (SELECT sensors.id FROM sensors WHERE sensors.name = sensor_values.name ) WHERE sensor_values.sensor_id = '';