mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-12-02 21:14:15 +01:00
Store layer relations in extra table.
This commit is contained in:
@@ -14,4 +14,17 @@ namespace Netzmacht\Contao\Leaflet\Model;
|
||||
class ControlModel extends AbstractActiveModel
|
||||
{
|
||||
protected static $strTable = 'tl_leaflet_control';
|
||||
|
||||
/**
|
||||
* @return \Model\Collection
|
||||
*/
|
||||
public function findLayers()
|
||||
{
|
||||
$query = 'SELECT l.*, c.mode as controlMode FROM tl_leaflet_layer l LEFT JOIN tl_leaflet_control_layer c ON l.id = c.lid WHERE c.cid=?';
|
||||
$result = \Database::getInstance()
|
||||
->prepare($query)
|
||||
->execute($this->id);
|
||||
|
||||
return \Model\Collection::createFromDbResult($result, 'tl_leaflet_layer');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,4 +16,16 @@ class MapModel extends \Model
|
||||
{
|
||||
protected static $strTable = 'tl_leaflet_map';
|
||||
|
||||
/**
|
||||
* @return \Model\Collection
|
||||
*/
|
||||
public function findLayers()
|
||||
{
|
||||
$query = 'SELECT l.* FROM tl_leaflet_layer l LEFT JOIN tl_leaflet_map_layer m ON l.id = m.lid WHERE m.mid=?';
|
||||
$result = \Database::getInstance()
|
||||
->prepare($query)
|
||||
->execute($this->id);
|
||||
|
||||
return \Model\Collection::createFromDbResult($result, 'tl_leaflet_layer');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user