Revize 01f99166
Přidáno uživatelem Jan Kohlíček před téměř 7 roky(ů)
backend/app/Model/Zarizeni.php | ||
---|---|---|
30 | 30 |
* |
31 | 31 |
* @return mixed |
32 | 32 |
*/ |
33 |
public static function getAllJoinAddress() { |
|
33 |
public static function getAllJoinAddress() |
|
34 |
{ |
|
34 | 35 |
return DB::table('zarizeni') |
35 | 36 |
->join('ulice', 'zarizeni.ulice_id', '=', 'ulice.id') |
36 | 37 |
->join('mesto', 'ulice.mesto_id', '=', 'mesto.id') |
... | ... | |
52 | 53 |
* @param $showDirection 1 pokud má být rozlišen směr zařízení. |
53 | 54 |
* @return mixed |
54 | 55 |
*/ |
55 |
public static function findByAddressJoinAddress($address, $showDirection) { |
|
56 |
public static function findByAddressJoinAddress($address, $showDirection) |
|
57 |
{ |
|
56 | 58 |
$query = DB::table('zarizeni') |
57 | 59 |
->join('ulice', 'zarizeni.ulice_id', '=', 'ulice.id') |
58 | 60 |
->join('mesto', 'ulice.mesto_id', '=', 'mesto.id') |
61 |
->join('zaznam_cas', 'zaznam_cas.zarizeni_id', '=', 'zarizeni.id') |
|
59 | 62 |
->select('zarizeni.id as id', |
60 | 63 |
'zarizeni.smer_popis as name', |
61 | 64 |
'ulice.nazev as street', |
... | ... | |
63 | 66 |
'ulice.lat as lat', |
64 | 67 |
'ulice.lng as lng', |
65 | 68 |
'mesto.nazev as town', |
66 |
'mesto.id as town_id') |
|
67 |
->where('ulice.nazev', 'like', '%'.$address.'%') |
|
68 |
->orWhere('mesto.nazev', 'like', '%'.$address.'%'); |
|
69 |
'mesto.id as town_id', |
|
70 |
$showDirection ? 'zaznam_cas.smer as direction' : DB::Raw('0 as direction')) |
|
71 |
->where('ulice.nazev', 'like', '%' . $address . '%') |
|
72 |
->orWhere('mesto.nazev', 'like', '%' . $address . '%') |
|
73 |
->orWhere('zarizeni.smer_popis', 'like', '%' . $address . '%'); |
|
69 | 74 |
|
70 | 75 |
if (!$showDirection) { |
71 |
$query = $query->groupBy('zarizeni.ulice_id'); |
|
76 |
$query = $query->groupBy('zarizeni.id'); |
|
77 |
} else { |
|
78 |
$query = $query->groupBy('zarizeni.id', 'zaznam_cas.smer'); |
|
72 | 79 |
} |
73 | 80 |
|
74 | 81 |
|
... | ... | |
82 | 89 |
* @param $id Id zarizeni. |
83 | 90 |
* @return mixed |
84 | 91 |
*/ |
85 |
public static function findByIdJoinAddress($id) { |
|
92 |
public static function findByIdJoinAddress($id) |
|
93 |
{ |
|
86 | 94 |
return DB::table('zarizeni') |
87 | 95 |
->join('ulice', 'zarizeni.ulice_id', '=', 'ulice.id') |
88 | 96 |
->join('mesto', 'ulice.mesto_id', '=', 'mesto.id') |
... | ... | |
120 | 128 |
*/ |
121 | 129 |
public $stav; |
122 | 130 |
|
123 |
public function ulice() { |
|
131 |
public function ulice() |
|
132 |
{ |
|
124 | 133 |
return $this->belongsTo('App\Model\Ulice'); |
125 | 134 |
} |
126 | 135 |
} |
Také k dispozici: Unified diff
refs #6948: Oprava REST API (/devices, /devices/{id}/time-period) a script pro přidání souřadnic