public static function handle($uri) { $definitions = \Definition::all(); // Polyfill if (!function_exists('array_column')) { function array_column($array, $column_name) { return array_map(function ($element) use($column_name) { return $element[$column_name]; }, $array); } } // Get unique properties $keywords = Definitions\KeywordController::getKeywordList($definitions); $languages = array_count_values(array_filter(array_column($definitions->toArray(), 'language'))); $licenses = array_count_values(array_filter(array_column($definitions->toArray(), 'rights'))); $themes = array_count_values(array_filter(array_column($definitions->toArray(), 'theme'))); $publishers = array_count_values(array_filter(array_column($definitions->toArray(), 'publisher_name'))); // Sort by "Popularity" // For alphabetical order: use ksort arsort($keywords); arsort($languages); arsort($licenses); arsort($themes); arsort($publishers); $view = \View::make('home')->with('title', 'Datasets | The Datatank')->with('page_title', 'Datasets')->with('keywords', $keywords)->with('languages', $languages)->with('licenses', $licenses)->with('themes', $themes)->with('publishers', $publishers)->with('definitions', $definitions); return \Response::make($view); }
/** * Admin.dataset.view */ public function getIndex() { // Set permission Auth::requirePermissions('admin.dataset.view'); // Get all definitions $definitions = \Definition::all(); return \View::make('ui.datasets.list')->with('title', 'Dataset management | The Datatank')->with('definitions', $definitions); }
public function testDeleteApi() { // Delete the published definition for each test csv file. foreach ($this->test_data as $file) { $this->updateRequest('DELETE'); $controller = \App::make('Tdt\\Core\\Definitions\\DefinitionController'); $response = $controller->handle("csv/{$file}"); $this->assertEquals(200, $response->getStatusCode()); } // Check if everything is deleted properly. $definitions_count = \Definition::all()->count(); $csv_count = \CsvDefinition::all()->count(); $this->assertTrue($csv_count == 0); $this->assertTrue($definitions_count == 0); }
/** * Run the migrations. * * @return void */ public function up() { Schema::table('definitions', function ($table) { $table->string('title', 255); }); // Denormalize the definitions by copying the existing titles and descriptions foreach (\Definition::all() as $definition) { $source_model = new $definition->source_type(); $source = $source_model->find($definition->source_id); if (!empty($source->title)) { $definition->title = $source->title; } if (!empty($source->description)) { $definition->description = $source->description; } $definition->save(); } }
/** * Run the migrations. * * @return void */ public function up() { Schema::create('definition_facet_types', function ($table) { $table->increments('id'); $table->string('facet_name', 255); }); $facet_types = ['rights', 'keyword', 'language', 'theme', 'publisher_name']; $facet_type_models = []; foreach ($facet_types as $facet) { $facet_type = \FacetType::create(['facet_name' => $facet]); $facet_type->save(); if ($facet != 'keyword') { $facet_type_model[$facet] = $facet_type; } else { $facet_type_model['keywords'] = $facet_type; } } Schema::create('definition_facets', function ($table) { $table->increments('id'); $table->integer('definition_id'); $table->integer('facet_id'); $table->string('facet_name'); $table->string('value'); }); // Copy all of the facet related info to the new definition_facets table $definitions = \Definition::all(); foreach ($definitions as $definition) { foreach ($facet_type_models as $facet_name => $facet_type) { if ($facet_name != 'keywords' && !empty($definition->{$facet_name})) { $facet = \Facet::create(['definition_id' => $definition->id, 'facet_id' => $facet_type->id, 'facet_name' => $facet_name, 'value' => $definition->{$facet_name}]); $facet->save(); } else { // split the keywords if (!empty($definition->keywords)) { $keywords = explode(',', $definition->keywords); foreach ($keywords as $keyword) { $facet = \Facet::create(['definition_id' => $definition->id, 'facet_id' => $facet_type->id, 'facet_name' => 'keyword', 'value' => $keyword]); $facet->save(); } } } } } }
public function count() { return \Definition::all()->count(); }
public static function handle($uri) { $definitions = \Definition::all(); $view = \View::make('home')->with('title', 'Datasets | The Datatank')->with('page_title', 'Datasets')->with('definitions', $definitions); return \Response::make($view); }