chartManD commited on
Commit
6ed81b9
·
1 Parent(s): 533e085

Add Models from local project

Browse files
models/Category.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Category
3
+ {
4
+ private $id_category;
5
+ private $name_category;
6
+
7
+ public function __construct($id, $name)
8
+ {
9
+ $this->id_category = !$id ? null : $id;
10
+ $this->name_category = $name;
11
+ }
12
+
13
+ public function getAtributs() : array
14
+ {
15
+ return ["id_categoria" => $this->id_category, "nombre_categoria" => $this->name_category];
16
+ }
17
+
18
+ public function getNameCategory() : string|null
19
+ {
20
+ return $this->name_category;
21
+ }
22
+ }
models/DetailsPlace.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class DetailsPlace
3
+ {
4
+ private $description;
5
+ private $descriptionFauna;
6
+ private $timeIdeal;
7
+ private $estimatedBudget;
8
+ private $nameLocality;
9
+ private $estiamatedSurface;
10
+ private $isProtected;
11
+ private $isPayToIn;
12
+ private $listEnvironmentalMeasures;
13
+ private $listSecurityMeasures;
14
+ private $listSeasons;
15
+ private $listActivitis;
16
+
17
+ public function __construct($_description, $_descriptionFauna, $_timeIdeal, $_estimatedBudget, $_nameLocality, $_estiamatedSurface, $_isProtected, $_isPayToIn)
18
+ {
19
+ $this->description = $_description;
20
+ $this->descriptionFauna = $_descriptionFauna;
21
+ $this->timeIdeal = $_timeIdeal;
22
+ $this->estimatedBudget = $_estimatedBudget;
23
+ $this->nameLocality = $_nameLocality;
24
+ $this->estiamatedSurface = $_estiamatedSurface;
25
+ $this->isProtected = $_isProtected;
26
+ $this->isPayToIn = $_isPayToIn;
27
+ $this->listEnvironmentalMeasures = array();
28
+ $this->listSecurityMeasures = array();
29
+ $this->listSeasons = array();
30
+ $this->listActivitis = array();
31
+ }
32
+
33
+ public function getRawDetails() : array
34
+ {
35
+ return [
36
+ "descripcion" => $this->description,
37
+ "fauna" => $this->descriptionFauna,
38
+ "tiempo_ideal" => $this->timeIdeal,
39
+ "presupuesto_estimado" => $this->estimatedBudget,
40
+ "localidad" => $this->nameLocality,
41
+ "superficie_estimada" => $this->estiamatedSurface,
42
+ "es_protegido" => $this->isProtected,
43
+ "se_paga" => $this->isPayToIn,
44
+ "medidas_ambientales" => $this->listEnvironmentalMeasures,
45
+ "medidas_seguridad" => $this->listSecurityMeasures,
46
+ "estaciones" => $this->listSeasons,
47
+ "actividades" => $this->listActivitis
48
+ ];
49
+ }
50
+
51
+ public function addEnvironmentalMeasure($measure)
52
+ {
53
+ array_push($this->listEnvironmentalMeasures, $measure);
54
+ }
55
+
56
+ public function addSecurityMeasure($measure)
57
+ {
58
+ array_push($this->listSecurityMeasures, $measure);
59
+ }
60
+
61
+ public function addSeaon($seaon)
62
+ {
63
+ array_push($this->listSeasons, $seaon);
64
+ }
65
+
66
+ public function addActivity($activity)
67
+ {
68
+ array_push($this->listActivitis, $activity);
69
+ }
70
+
71
+ public function isThereEnvironmentalMeasure($measure) : bool
72
+ {
73
+ return in_array($measure, $this->listEnvironmentalMeasures);
74
+ }
75
+
76
+ public function isThereSecurityMeasure($measure) : bool
77
+ {
78
+ return in_array($measure, $this->listSecurityMeasures);
79
+ }
80
+
81
+ public function isThereSeason($seaon) : bool
82
+ {
83
+ return in_array($seaon, $this->listSeasons);
84
+ }
85
+
86
+ public function isThereActivity($activity) : bool
87
+ {
88
+ return in_array($activity, $this->listActivitis);
89
+ }
90
+ }
models/ImageGalery.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class ImageGalery
3
+ {
4
+ private $idImg;
5
+ private $urlImg;
6
+ private $namePlace;
7
+
8
+ public function __construct($id, $url, $name)
9
+ {
10
+ $this->idImg = $id;
11
+ $this->urlImg = $url;
12
+ $this->namePlace = $name;
13
+ }
14
+
15
+ public function getAtributes()
16
+ {
17
+ return ["id" => $this->idImg, "url" => $this->urlImg, "nombreLugar" => $this->namePlace];
18
+ }
19
+ }
models/Locate.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Locate
3
+ {
4
+ private $latitud;
5
+ private $altitud;
6
+ private $longitud;
7
+
8
+ public function __construct($lat, $alt, $long)
9
+ {
10
+ $this->latitud = $lat;
11
+ $this->altitud = $alt;
12
+ $this->longitud = $long;
13
+ }
14
+
15
+ public function getCoordinates() : array
16
+ {
17
+ return ["latitud" => $this->latitud, "altitud" => $this->altitud, "longitud" => $this->longitud];
18
+ }
19
+ }
models/Place.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Place
3
+ {
4
+ private $idPlace;
5
+ private $namePlace;
6
+ private $frondPage;
7
+ private $timeTransport;
8
+ private $listCategoryPlace;
9
+
10
+ public function __construct($id, $name, $frond)
11
+ {
12
+ $this->idPlace = $id;
13
+ $this->namePlace = $name;
14
+ $this->frondPage = $frond;
15
+ $this->timeTransport = array();
16
+ $this->listCategoryPlace = array();
17
+ }
18
+
19
+ public function getRawPlace() : array
20
+ {
21
+ $arrRawTimeTransport = array();
22
+ foreach ($this->timeTransport as $trasnport) {
23
+ if ($trasnport->getNameTransport() != null) {
24
+ array_push($arrRawTimeTransport, $trasnport->getTransportTime());
25
+ }
26
+ }
27
+
28
+ $arrRawCategory = array();
29
+ foreach ($this->listCategoryPlace as $category) {
30
+ if ($category->getNameCategory() != null) {
31
+ array_push($arrRawCategory, $category->getNameCategory());
32
+ }
33
+ }
34
+
35
+ $data = [
36
+ "id_lugar" => $this->idPlace,
37
+ "nombre_lugar" => $this->namePlace,
38
+ "portada" => $this->frondPage,
39
+ "tiempos_llegada" => $arrRawTimeTransport,
40
+ "categorias" => $arrRawCategory
41
+ ];
42
+
43
+ return $data;
44
+ }
45
+
46
+ public function addTransport($newTransport)
47
+ {
48
+ array_push($this->timeTransport, $newTransport);
49
+ }
50
+
51
+ public function addCategory($newCategory)
52
+ {
53
+ array_push($this->listCategoryPlace, $newCategory);
54
+ }
55
+
56
+ public function isExistTransports($nameToCompare) : bool
57
+ {
58
+ $namesTrasnports = array();
59
+
60
+ foreach ($this->timeTransport as $transport) {
61
+ array_push($namesTrasnports, $transport->getNameTransport());
62
+ }
63
+
64
+ return in_array($nameToCompare, $namesTrasnports);
65
+ }
66
+
67
+ public function isExistCategory($nameToCompare) : bool
68
+ {
69
+ $namesCategorys = array();
70
+
71
+ foreach ($this->listCategoryPlace as $category) {
72
+ array_push($namesCategorys, $category->getNameCategory());
73
+ }
74
+
75
+ return in_array($nameToCompare, $namesCategorys);
76
+ }
77
+ }
models/Trasnport.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Transport
3
+ {
4
+ public $nameTransport;
5
+ public $timeRoad;
6
+
7
+ public function __construct($name, $time)
8
+ {
9
+ $this->nameTransport = $name;
10
+ $this->timeRoad = $time;
11
+ }
12
+
13
+ public function getTransportTime() : array
14
+ {
15
+ return ["trasnporte" => $this->nameTransport, "tiempo" => $this->timeRoad];
16
+ }
17
+
18
+ public function getNameTransport() : string|null
19
+ {
20
+ return $this->nameTransport;
21
+ }
22
+ }