--- /dev/null
+<?php
+
+namespace App\Console\Commands;
+
+use Illuminate\Console\Command;
+
+class SearchIndex extends Command
+{
+ protected $signature = 'odl:searchindex';
+ protected $description = 'Make the search index';
+
+ public function handle()
+ {
+ \App\Jobs\SearchIndex::dispatchSync();
+ }
+
+}
--- /dev/null
+<?php
+
+namespace App\Jobs;
+
+use App\Models\Resource;
+use Cubist\Backpack\Magic\PageData;
+use Cubist\Minisearch\Document\PDF;
+use Cubist\Minisearch\Index;
+
+class SearchIndex extends Index
+{
+ public function __construct()
+ {
+ $this->output = storage_path('search.js');
+ }
+
+ public function handle()
+ {
+ $this->indexHome();
+ $this->indexLibrary();
+ $this->indexResources();
+ $this->indexTour();
+
+ parent::handle();
+ }
+
+ public function indexHome()
+ {
+
+ }
+
+ public function indexLibrary()
+ {
+
+ }
+
+ public function indexResources()
+ {
+ /** @var PageData $data */
+ $data = Resource::find('1')->getPageData();
+
+ $chapters = $data->get('chapters');
+ foreach ($chapters as $i => $chapter) {
+ foreach ($chapter['subchapters'] as $j => $subchapter) {
+ foreach ($subchapter['subchapter_memos'] as $k => $memo) {
+ if (!$memo['memo_pdf']) {
+ continue;
+ }
+ foreach ($data->getMediaPathsByCollection($memo['memo_pdf']) as $pdf) {
+ $document = new PDF($pdf);
+ $document->setId('resources_' . $i . '_' . $j . '_' . $k);
+ $document->setUrl('resources_' . $i . '_' . $j . '_' . $k);
+ $document->setTitle($memo['memo_title']);
+ $document->setThumb($data->getImageURLbyCollection($memo['memo_image']));
+ $document->setType('pdf');
+ $this->addDocument($document);
+ break;
+ }
+
+ }
+ }
+ }
+
+ }
+
+ public function indexTour()
+ {
+
+ }
+
+}
"name": "odl/cube",
"type": "project",
"description": "ODL Framework.",
- "keywords": ["framework", "laravel"],
+ "keywords": [
+ "framework",
+ "laravel"
+ ],
"repositories": [
{
"type": "composer",
"ext-tidy": "*",
"ext-zip": "*",
"cubist/cms-back": "dev-master",
+ "cubist/minisearch": "dev-master",
"cubist/socialite": "dev-master",
"fluidbook/tools": "dev-master",
"fruitcake/laravel-cors": "^2.0",