Skip to content

Commit

Permalink
feat(point): add Point model
Browse files Browse the repository at this point in the history
  • Loading branch information
0x1026 committed Nov 16, 2024
1 parent 12463b2 commit 3552a12
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
5 changes: 3 additions & 2 deletions docker/database/start-scripts/0-init.sql
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
8 changes: 7 additions & 1 deletion docker/database/start-scripts/1-seed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
('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);
25 changes: 25 additions & 0 deletions src/app/Models/Point.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace App\Models;

use App\Core\BaseModel;

class Point extends BaseModel
{
public $latitude;
public $longitude;

protected static function getTableName()
{
return 'points';
}

protected static function mapDataToModel($data)
{
$point = new Point();
$point->id = $data['id'];
$point->latitude = $data['latitude'];
$point->longitude = $data['longitude'];
return $point;
}
}

0 comments on commit 3552a12

Please sign in to comment.