From 3552a12f4f3808479f5d48ecefcbeb2c3ed9332d Mon Sep 17 00:00:00 2001 From: 0x1026 <69076992+0x1026@users.noreply.github.com> Date: Sat, 16 Nov 2024 22:02:40 +0100 Subject: [PATCH] feat(point): add Point model --- docker/database/start-scripts/0-init.sql | 5 +++-- docker/database/start-scripts/1-seed.sql | 8 +++++++- src/app/Models/Point.php | 25 ++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 src/app/Models/Point.php diff --git a/docker/database/start-scripts/0-init.sql b/docker/database/start-scripts/0-init.sql index e18c9fac..760c20e1 100644 --- a/docker/database/start-scripts/0-init.sql +++ b/docker/database/start-scripts/0-init.sql @@ -1,7 +1,8 @@ create table points ( id int auto_increment primary key, - latitude decimal, - longitude decimal + latitude decimal(10, 7) not null, + longitude decimal(10, 7) not null, + constraint UC_Point unique (latitude, longitude) ); create table zones ( diff --git a/docker/database/start-scripts/1-seed.sql b/docker/database/start-scripts/1-seed.sql index 9c3ca232..6d903f67 100644 --- a/docker/database/start-scripts/1-seed.sql +++ b/docker/database/start-scripts/1-seed.sql @@ -32,4 +32,10 @@ INSERT INTO task_types (name) VALUES INSERT INTO pruning_types (name, description) VALUES ('A', 'Poda de mantenimiento en árbol tipo A, caduco, de p.c. entre 41/80 cm.'), ('B', 'Poda de mantenimiento en árbol tipo B, caduco, de p.c. mayor de 81 cm.'), -('C', 'Poda de mantenimiento en árbol tipo C, perenne, de p.c. entre 41/60 cm.'); \ No newline at end of file +('C', 'Poda de mantenimiento en árbol tipo C, perenne, de p.c. entre 41/60 cm.'); + +-- Insert sample points +INSERT INTO points (latitude, longitude) VALUES +(40.416775, -3.703790), +(40.416776, -3.703795), +(40.416777, -3.703800); diff --git a/src/app/Models/Point.php b/src/app/Models/Point.php new file mode 100644 index 00000000..a586a6e3 --- /dev/null +++ b/src/app/Models/Point.php @@ -0,0 +1,25 @@ +id = $data['id']; + $point->latitude = $data['latitude']; + $point->longitude = $data['longitude']; + return $point; + } +}