本文整理汇总了PHP中Definition::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Definition::where方法的具体用法?PHP Definition::where怎么用?PHP Definition::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Definition
的用法示例。
在下文中一共展示了Definition::where方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: seedShp
/**
* Seed the SHP definitions
*/
private function seedShp()
{
$shp_data = array('rivers' => array('file' => 'gis.osm_boundaries_v06', 'collection' => 'dresden', 'name' => 'rivers', 'description' => 'Shape file about rivers in Dresden.', 'columns' => array(array('column_name' => 'osm_id', 'index' => 0, 'column_name_alias' => 'osm_id', 'is_pk' => 0), array('column_name' => 'lastchange', 'index' => 1, 'column_name_alias' => 'lastchange', 'is_pk' => 0), array('column_name' => 'code', 'index' => 2, 'column_name_alias' => 'code', 'is_pk' => 0), array('column_name' => 'fclass', 'index' => 3, 'column_name_alias' => 'fclass', 'is_pk' => 0), array('column_name' => 'deleted', 'index' => 4, 'column_name_alias' => 'deleted', 'is_pk' => 0), array('column_name' => 'parts', 'index' => 5, 'column_name_alias' => 'parts', 'is_pk' => 0)), 'geo' => array(array('path' => 'parts', 'property' => 'polyline'))), 'places' => array('file' => 'places', 'name' => 'places', 'collection' => 'france', 'description' => 'Interesting places from "Ile-de-France".', 'columns' => array(array('column_name' => 'osm_id', 'index' => 0, 'column_name_alias' => 'osm_id', 'is_pk' => 0), array('column_name' => 'name', 'index' => 1, 'column_name_alias' => 'name', 'is_pk' => 0), array('column_name' => 'type', 'index' => 2, 'column_name_alias' => 'type', 'is_pk' => 0), array('column_name' => 'population', 'index' => 3, 'column_name_alias' => 'population', 'is_pk' => 0), array('column_name' => 'deleted', 'index' => 4, 'column_name_alias' => 'deleted', 'is_pk' => 0), array('column_name' => 'x', 'index' => 5, 'column_name_alias' => 'x', 'is_pk' => 0), array('column_name' => 'y', 'index' => 6, 'column_name_alias' => 'y', 'is_pk' => 0)), 'geo' => array(array('path' => 'x', 'property' => 'latitude'), array('path' => 'y', 'property' => 'longitude'))));
$added = false;
foreach ($shp_data as $directory => $info) {
// Don't create doubles
$definition = Definition::where('collection_uri', '=', $info['collection'])->where('resource_name', '=', $info['name'])->first();
if (empty($definition)) {
// Create a new ShpDefinition
$shp_def = new ShpDefinition();
$shp_def->uri = app_path() . '/storage/data/shp/' . $directory . '/' . $info['file'] . '.shp';
$shp_def->description = $info['description'];
$shp_def->epsg = 4326;
$shp_def->save();
// Add the tabular columns
foreach ($info['columns'] as $column) {
$tab_column = new TabularColumns();
$tab_column->column_name = $column['column_name'];
$tab_column->index = $column['index'];
$tab_column->column_name_alias = $column['column_name_alias'];
$tab_column->is_pk = $column['is_pk'];
$tab_column->tabular_id = $shp_def->id;
$tab_column->tabular_type = 'ShpDefinition';
$tab_column->save();
}
// Add the geo properties
foreach ($info['geo'] as $geo) {
$geo_prop = new GeoProperty();
$geo_prop->source_type = 'ShpDefinition';
$geo_prop->source_id = $shp_def->id;
$geo_prop->property = $geo['property'];
$geo_prop->path = $geo['path'];
$geo_prop->save();
}
// Add the ShpDefinition to the Definition
$definition = new Definition();
$definition->collection_uri = $info['collection'];
$definition->resource_name = $info['name'];
$definition->source_id = $shp_def->id;
$definition->source_type = 'ShpDefinition';
$definition->draft = false;
$definition->save();
$this->command->info("Published a SHP file.");
$added = true;
}
}
if (!$added) {
$this->command->info("No SHP files have been published, all of the uri's that the SHP seeder wanted to use are already taken.");
}
}
示例2: getAllDefinitionInfo
public function getAllDefinitionInfo($limit, $offset, $keywords = [])
{
if (!empty($keywords)) {
$filtered_definitions = [];
$count = 0;
$skipped = 0;
foreach ($keywords as $keyword) {
$definitions = \Definition::where('keywords', 'LIKE', '%' . $keyword . '%')->get();
$definition_count = $definitions->count();
if ($definition_count >= $offset || $count <= $limit + $offset) {
// Use the slice(offset, amount) function on the Collection object
if ($count < $offset) {
$eligable_definitions = $definitions->slice($offset - $count, $limit - $count);
foreach ($eligable_definitions as $eligable_definition) {
$filtered_definitions[] = $eligable_definition->toArray();
}
} elseif ($count < $limit + $offset) {
$eligable_definitions = $definitions->slice(0, $limit - $count + 1);
foreach ($eligable_definitions as $eligable_definition) {
$filtered_definitions[] = $eligable_definition->toArray();
}
}
}
$count += $definition_count;
}
$filtered_info = [];
foreach ($filtered_definitions as $filtered_definition) {
$identifier = $filtered_definition['collection_uri'] . '/' . $filtered_definition['resource_name'];
$filtered_info[$identifier] = $this->getDescriptionInfo($identifier);
}
return $filtered_info;
} else {
$definitions = array();
foreach ($this->getAll($limit, $offset) as $definition) {
$identifier = $definition['collection_uri'] . '/' . $definition['resource_name'];
$definitions[$identifier] = $this->getDescriptionInfo($identifier);
}
}
return $definitions;
}
示例3: seedShp
/**
* Seed the SHP definitions
*/
private function seedShp()
{
$shp_config = ['collection_uri' => 'dresden', 'resource_name' => 'rivers', 'title' => 'Dresden rivers', 'uri' => app_path() . '/storage/data/shp/rivers/gis.osm_boundaries_v06.shp', 'epsg' => 4326, 'type' => 'shp', 'rights' => 'License Not Specified', 'keywords' => 'dresden, geographical', 'description' => 'Shape file containing the rivers in the city Dresden.', 'columns' => array(array('column_name' => 'osm_id', 'index' => 0, 'column_name_alias' => 'osm_id', 'is_pk' => 0), array('column_name' => 'lastchange', 'index' => 1, 'column_name_alias' => 'lastchange', 'is_pk' => 0), array('column_name' => 'code', 'index' => 2, 'column_name_alias' => 'code', 'is_pk' => 0), array('column_name' => 'fclass', 'index' => 3, 'column_name_alias' => 'fclass', 'is_pk' => 0), array('column_name' => 'deleted', 'index' => 4, 'column_name_alias' => 'deleted', 'is_pk' => 0), array('column_name' => 'parts', 'index' => 5, 'column_name_alias' => 'parts', 'is_pk' => 0)), 'geo' => array(array('path' => 'parts', 'property' => 'polyline'))];
$definition = Definition::where('collection_uri', '=', 'dresden')->where('resource_name', '=', 'rivers')->first();
if (empty($definition)) {
$this->definitions->store($shp_config);
$this->command->info("Published a SHP dataset.");
} else {
$this->command->info("No SHP files have been published, all of the uri's that the SHP seeder wanted to use are already taken.");
}
}
示例4: countPublished
/**
* Return the count of all non-draft definitions
*/
public function countPublished()
{
return \Definition::where('draft', '=', 0)->count();
}
示例5: getOldest
public function getOldest()
{
$definition = \Definition::where('updated_at', '=', \DB::table('definitions')->max('updated_at'))->first();
if (!empty($definition)) {
return $definition->toArray();
}
return $definition;
}