all models into model folder

This commit is contained in:
Arno Kaimbacher 2018-09-10 15:09:10 +02:00
parent 98f50a2b6f
commit 6990469c67
46 changed files with 325 additions and 203 deletions

View File

@ -17,7 +17,7 @@ class Book extends Model
public function project() public function project()
{ {
return $this->belongsTo('App\Project', 'project_id', 'id'); return $this->belongsTo('App\Models\Project', 'project_id', 'id');
} }
// public function shelf() // public function shelf()

View File

@ -1,14 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Collection extends Model
{
public function documents()
{
return $this->belongsToMany(\App\Dataset::class, 'link_documents_collections', 'collection_id', 'document_id');
}
}

View File

@ -2,7 +2,7 @@
namespace App\Http\Controllers\Auth; namespace App\Http\Controllers\Auth;
use App\User; use App\Models\User;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Foundation\Auth\RegistersUsers;

View File

@ -4,7 +4,7 @@ namespace App\Http\Controllers;
use App\Http\Requests; use App\Http\Requests;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Book; use App\Book;
use App\Project; use App\Models\Project;
use App\Shelf; use App\Shelf;
use App\Http\Requests\BookRequest; use App\Http\Requests\BookRequest;
use Illuminate\Http\Request; use Illuminate\Http\Request;

View File

@ -5,14 +5,12 @@ use App\Http\Controllers\Controller;
use App\Book; use App\Book;
use App\Person; use App\Person;
use App\Transaction; use App\Transaction;
use App\Project; use App\Models\Project;
use App\Http\Requests\PeminjamanRequest; use App\Http\Requests\PeminjamanRequest;
use Illuminate\Http\Request; use Illuminate\Http\Request;
class BorrowController extends Controller class BorrowController extends Controller
{ {
public function __construct() public function __construct()
{ {
$this->middleware('auth'); $this->middleware('auth');

View File

@ -17,6 +17,10 @@ class HomeController extends Controller
{ {
//$this->middleware('auth'); //$this->middleware('auth');
} }
public function test(): View
{
return view('welcome');
}
/** /**
* Show the application dashboard. * Show the application dashboard.
@ -43,7 +47,6 @@ class HomeController extends Controller
// } // }
return view('frontend.home.index'); return view('frontend.home.index');
// return view('welcome');
} }
/** /**

View File

@ -2,8 +2,7 @@
namespace App\Http\Controllers\Frontend; namespace App\Http\Controllers\Frontend;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Dataset; use App\Models\Dataset;
use Illuminate\Http\Request;
use Illuminate\View\View; use Illuminate\View\View;
class PagesController extends Controller class PagesController extends Controller

View File

@ -2,7 +2,7 @@
namespace App\Http\Controllers\Frontend; namespace App\Http\Controllers\Frontend;
use App\Book; use App\Book;
use App\Dataset; use App\Models\Dataset;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Library\Search\Navigation; use App\Library\Search\Navigation;
use App\Library\Util\SolrSearchSearcher; use App\Library\Util\SolrSearchSearcher;

View File

@ -1,8 +1,8 @@
<?php <?php
namespace App\Http\Controllers\Frontend; namespace App\Http\Controllers\Frontend;
use App\Models\Dataset;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Dataset;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
class SitelinkController extends Controller class SitelinkController extends Controller
@ -24,7 +24,7 @@ class SitelinkController extends Controller
return view('frontend.sitelink.index')->with(['years' => $this->years, 'documents' => $this->ids]); return view('frontend.sitelink.index')->with(['years' => $this->years, 'documents' => $this->ids]);
} }
public function list($year) public function listDocs($year)
{ {
$this->index(); $this->index();
if (preg_match('/^\d{4}$/', $year) > 0) { if (preg_match('/^\d{4}$/', $year) > 0) {
@ -34,7 +34,7 @@ class SitelinkController extends Controller
$select = Dataset::with('titles', 'authors') $select = Dataset::with('titles', 'authors')
->where('server_state', 'LIKE', "%" . $serverState . "%"); ->where('server_state', 'LIKE', "%" . $serverState . "%");
$from = (int)$year; $from = (int) $year;
$until = $year + 1; $until = $year + 1;
$select $select
->whereYear('server_date_published', '>=', $from) ->whereYear('server_date_published', '>=', $from)

View File

@ -3,9 +3,8 @@ namespace App\Http\Controllers\Oai;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Dataset; use App\Models\Dataset;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Book;
class RequestController extends Controller class RequestController extends Controller
{ {
@ -15,7 +14,7 @@ class RequestController extends Controller
* *
* @var array * @var array
*/ */
private $_deliveringDocumentStates = array('published', 'deleted'); // maybe deleted documents too private $deliveringDocumentStates = array('published', 'deleted'); // maybe deleted documents too
const SET_SPEC_PATTERN = '[A-Za-z0-9\-_\.!~\*\'\(\)]+'; const SET_SPEC_PATTERN = '[A-Za-z0-9\-_\.!~\*\'\(\)]+';
@ -31,7 +30,7 @@ class RequestController extends Controller
* *
* @var \DomDocument Defaults to null. * @var \DomDocument Defaults to null.
*/ */
protected $_xslt = null; protected $xslt = null;
/** /**
* Holds the xslt processor. * Holds the xslt processor.
@ -47,9 +46,9 @@ class RequestController extends Controller
*/ */
private function loadStyleSheet($stylesheet) private function loadStyleSheet($stylesheet)
{ {
$this->_xslt = new \DomDocument; $this->xslt = new \DomDocument;
$this->_xslt->load($stylesheet); $this->xslt->load($stylesheet);
$this->_proc->importStyleSheet($this->_xslt); $this->_proc->importStyleSheet($this->xslt);
if (isset($_SERVER['HTTP_HOST'])) { if (isset($_SERVER['HTTP_HOST'])) {
$this->_proc->setParameter('', 'host', $_SERVER['HTTP_HOST']); $this->_proc->setParameter('', 'host', $_SERVER['HTTP_HOST']);
} }
@ -91,22 +90,22 @@ class RequestController extends Controller
if (isset($oaiRequest['verb'])) { if (isset($oaiRequest['verb'])) {
$this->_proc->setParameter('', 'oai_verb', $oaiRequest['verb']); $this->_proc->setParameter('', 'oai_verb', $oaiRequest['verb']);
if ($oaiRequest['verb'] == 'Identify') { if ($oaiRequest['verb'] == 'Identify') {
$this->_handleIdentify(); $this->handleIdentify();
} elseif ($oaiRequest['verb'] == 'ListMetadataFormats') { } elseif ($oaiRequest['verb'] == 'ListMetadataFormats') {
$this->_handleListMetadataFormats(); $this->handleListMetadataFormats();
} elseif ($oaiRequest['verb'] == 'ListRecords') { } elseif ($oaiRequest['verb'] == 'ListRecords') {
$this->_handleListRecords($oaiRequest); $this->handleListRecords($oaiRequest);
} elseif ($oaiRequest['verb'] == 'ListIdentifiers') { } elseif ($oaiRequest['verb'] == 'ListIdentifiers') {
$this->_handleListIdentifiers($oaiRequest); $this->handleListIdentifiers($oaiRequest);
} elseif ($oaiRequest['verb'] == 'ListSets') { } elseif ($oaiRequest['verb'] == 'ListSets') {
$this->_handleListSets($oaiRequest); $this->handleListSets($oaiRequest);
} else { } else {
$this->_handleIllegalVerb(); $this->handleIllegalVerb();
} }
} else { } else {
$oaiRequest['verb'] = 'Identify'; $oaiRequest['verb'] = 'Identify';
$this->_proc->setParameter('', 'oai_verb', $oaiRequest['verb']); $this->_proc->setParameter('', 'oai_verb', $oaiRequest['verb']);
$this->doc = $this->_handleIdentify(); $this->doc = $this->handleIdentify();
} }
//$xml = $this->_xml->saveXML(); //$xml = $this->_xml->saveXML();
@ -123,7 +122,7 @@ class RequestController extends Controller
* *
* @return void * @return void
*/ */
private function _handleIdentify() private function handleIdentify()
{ {
$email = "repository@geologie.ac.at"; $email = "repository@geologie.ac.at";
$repositoryName = "Data Research Repository"; $repositoryName = "Data Research Repository";
@ -149,7 +148,7 @@ class RequestController extends Controller
* @param array &$oaiRequest Contains full request information * @param array &$oaiRequest Contains full request information
* @return void * @return void
*/ */
private function _handleListMetadataFormats() private function handleListMetadataFormats()
{ {
$this->_xml->appendChild($this->_xml->createElement('Documents')); $this->_xml->appendChild($this->_xml->createElement('Documents'));
} }
@ -160,10 +159,10 @@ class RequestController extends Controller
* @param array &$oaiRequest Contains full request information * @param array &$oaiRequest Contains full request information
* @return void * @return void
*/ */
private function _handleListRecords($oaiRequest) private function handleListRecords($oaiRequest)
{ {
$maxRecords = 20;//$this->_configuration->getMaxListRecords(); $maxRecords = 20;//$this->_configuration->getMaxListRecords();
$this->_handlingOfLists($oaiRequest, $maxRecords); $this->handlingOfLists($oaiRequest, $maxRecords);
} }
/** /**
@ -172,10 +171,10 @@ class RequestController extends Controller
* @param array &$oaiRequest Contains full request information * @param array &$oaiRequest Contains full request information
* @return void * @return void
*/ */
private function _handleListIdentifiers(array &$oaiRequest) private function handleListIdentifiers(array &$oaiRequest)
{ {
$maxIdentifier = 20;//$this->_configuration->getMaxListIdentifiers(); $maxIdentifier = 20;//$this->_configuration->getMaxListIdentifiers();
$this->_handlingOfLists($oaiRequest, $maxIdentifier); $this->handlingOfLists($oaiRequest, $maxIdentifier);
} }
/** /**
@ -184,7 +183,7 @@ class RequestController extends Controller
* @param array &$oaiRequest Contains full request information * @param array &$oaiRequest Contains full request information
* @return void * @return void
*/ */
private function _handleListSets() private function handleListSets()
{ {
$repIdentifier = "rdr.gba.ac.at"; $repIdentifier = "rdr.gba.ac.at";
$this->_proc->setParameter('', 'repIdentifier', $repIdentifier); $this->_proc->setParameter('', 'repIdentifier', $repIdentifier);
@ -216,7 +215,7 @@ class RequestController extends Controller
} }
private function _handleIllegalVerb() private function handleIllegalVerb()
{ {
$this->_proc->setParameter('', 'oai_error_code', 'badVerb'); $this->_proc->setParameter('', 'oai_error_code', 'badVerb');
$this->_proc->setParameter('', 'oai_error_message', 'The verb provided in the request is illegal.'); $this->_proc->setParameter('', 'oai_error_message', 'The verb provided in the request is illegal.');
@ -231,7 +230,7 @@ class RequestController extends Controller
* *
* @return void * @return void
*/ */
private function _handlingOfLists(array &$oaiRequest, $maxRecords) private function handlingOfLists(array &$oaiRequest, $maxRecords)
{ {
if (true === empty($maxRecords)) { if (true === empty($maxRecords)) {
$maxRecords = 100; $maxRecords = 100;
@ -255,7 +254,7 @@ class RequestController extends Controller
// no resumptionToken is given // no resumptionToken is given
$finder = Dataset::query(); $finder = Dataset::query();
// add server state restrictions // add server state restrictions
$finder->whereIn('server_state', $this->_deliveringDocumentStates); $finder->whereIn('server_state', $this->deliveringDocumentStates);
if (array_key_exists('set', $oaiRequest)) { if (array_key_exists('set', $oaiRequest)) {
$setarray = explode(':', $oaiRequest['set']); $setarray = explode(':', $oaiRequest['set']);
if ($setarray[0] == 'doc-type') { if ($setarray[0] == 'doc-type') {
@ -283,7 +282,7 @@ class RequestController extends Controller
//$node = $this->_xml->createElement('Rdr_Dataset'); //$node = $this->_xml->createElement('Rdr_Dataset');
$domNode = $this->getDatasetXmlDomNode($dataset); $domNode = $this->getDatasetXmlDomNode($dataset);
// add frontdoor url // add frontdoor url
$this->_addLandingPageAttribute($domNode, $dataset->id); $this->addLandingPageAttribute($domNode, $dataset->id);
// add access rights to element // add access rights to element
//$this->_addAccessRights($domNode, $dataset); //$this->_addAccessRights($domNode, $dataset);
@ -301,8 +300,8 @@ class RequestController extends Controller
//$node->appendChild($child); //$node->appendChild($child);
//$type = $dataset->type; //$type = $dataset->type;
$this->_addSpecInformation($node, 'doc-type:' . $dataset->type); $this->addSpecInformation($node, 'doc-type:' . $dataset->type);
//$this->_addSpecInformation($node, 'bibliography:' . 'false'); //$this->addSpecInformation($node, 'bibliography:' . 'false');
$this->_xml->documentElement->appendChild($node); $this->_xml->documentElement->appendChild($node);
} }
@ -314,7 +313,7 @@ class RequestController extends Controller
* @param string $docid Id of the dataset * @param string $docid Id of the dataset
* @return void * @return void
*/ */
private function _addLandingPageAttribute(\DOMNode $document, $dataid) private function addLandingPageAttribute(\DOMNode $document, $dataid)
{ {
$url = route('frontend.dataset.show', $dataid); $url = route('frontend.dataset.show', $dataid);
@ -324,7 +323,7 @@ class RequestController extends Controller
$document->appendChild($attr); $document->appendChild($attr);
} }
private function _addSpecInformation(\DOMNode $document, $information) private function addSpecInformation(\DOMNode $document, $information)
{ {
$setSpecAttribute = $this->_xml->createAttribute('Value'); $setSpecAttribute = $this->_xml->createAttribute('Value');
$setSpecAttributeValue = $this->_xml->createTextNode($information); $setSpecAttributeValue = $this->_xml->createTextNode($information);
@ -338,7 +337,7 @@ class RequestController extends Controller
private function getDatasetXmlDomNode($dataset) private function getDatasetXmlDomNode($dataset)
{ {
if (!in_array($dataset->server_state, $this->_deliveringDocumentStates)) { if (!in_array($dataset->server_state, $this->deliveringDocumentStates)) {
$message = 'Trying to get a document in server state "' . $dataset->server_state . '"'; $message = 'Trying to get a document in server state "' . $dataset->server_state . '"';
//Zend_Registry::get('Zend_Log')->err($message); //Zend_Registry::get('Zend_Log')->err($message);
Log::error("server state: $message"); Log::error("server state: $message");
@ -349,7 +348,7 @@ class RequestController extends Controller
$xmlModel = new \App\Library\Xml\XmlModel(); $xmlModel = new \App\Library\Xml\XmlModel();
$xmlModel->setModel($dataset); $xmlModel->setModel($dataset);
$xmlModel->excludeEmptyFields(); $xmlModel->excludeEmptyFields();
$xmlModel->setXmlCache(new \App\XmlCache()); $xmlModel->setXmlCache(new \App\Models\XmlCache());
return $xmlModel->getDomDocument()->getElementsByTagName('Rdr_Dataset')->item(0); return $xmlModel->getDomDocument()->getElementsByTagName('Rdr_Dataset')->item(0);
} }
@ -362,7 +361,7 @@ class RequestController extends Controller
$setSpecPattern = self::SET_SPEC_PATTERN; $setSpecPattern = self::SET_SPEC_PATTERN;
$sets = array(); $sets = array();
$finder = new \App\DatasetFinder(); $finder = new \App\Models\DatasetFinder();
$finder->setServerState('published'); $finder->setServerState('published');
foreach ($finder->groupedTypesPlusCount() as $doctype => $row) { foreach ($finder->groupedTypesPlusCount() as $doctype => $row) {
if (0 == preg_match("/^$setSpecPattern$/", $doctype)) { if (0 == preg_match("/^$setSpecPattern$/", $doctype)) {
@ -383,14 +382,22 @@ class RequestController extends Controller
private function handleIdentifyOld() private function handleIdentifyOld()
{ {
//$earliestDateFromDb = Opus_Document::getEarliestPublicationDate(); //$earliestDateFromDb = Opus_Document::getEarliestPublicationDate();
//$earliestDateFromDb = Dataset::select('server_date_created')->orderBy('server_date_created', 'desc')->first()->toDateTimeString(); // $earliestDateFromDb = Dataset::select('server_date_created')
// ->orderBy('server_date_created', 'desc')
// ->first()->toDateTimeString();
$earliestDateFromDb = Dataset::earliestPublicationDate(); $earliestDateFromDb = Dataset::earliestPublicationDate();
$sxe = new \SimpleXMLElement('<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="xsl/oai2.xslt"?><OAI-PMH/>'); $sxe = new \SimpleXMLElement(
'<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="xsl/oai2.xslt"?><OAI-PMH/>'
);
$sxe->addAttribute('xmlns', 'http://www.openarchives.org/OAI/2.0/'); $sxe->addAttribute('xmlns', 'http://www.openarchives.org/OAI/2.0/');
$sxe->addAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $sxe->addAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$sxe->addAttribute('xmlns:mml', 'http://www.w3.org/1998/Math/MathML'); $sxe->addAttribute('xmlns:mml', 'http://www.w3.org/1998/Math/MathML');
$sxe->addAttribute('xsi:schemaLocation', 'http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd'); $sxe->addAttribute(
'xsi:schemaLocation',
'http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd'
);
$sxe->addChild('responseDate', date("Y-m-d\TH:i:s\Z")); $sxe->addChild('responseDate', date("Y-m-d\TH:i:s\Z"));
$uri = explode('?', $_SERVER['REQUEST_URI'], 2); $uri = explode('?', $_SERVER['REQUEST_URI'], 2);
@ -411,7 +418,7 @@ class RequestController extends Controller
//$oaiIdentifier->addAttribute('xmlns', 'http://www.openarchives.org/OAI/2.0/oai-identifier'); //$oaiIdentifier->addAttribute('xmlns', 'http://www.openarchives.org/OAI/2.0/oai-identifier');
//$oaiIdentifier->addAttribute('xsi:schemaLocation', 'http://www.openarchives.org/OAI/2.0/oai-identifier'); //$oaiIdentifier->addAttribute('xsi:schemaLocation', 'http://www.openarchives.org/OAI/2.0/oai-identifier');
//$oaiIdentifier->addChild('scheme', 'oai'); //$oaiIdentifier->addChild('scheme', 'oai');
return $sxe; return $sxe;
} }
} }

View File

@ -2,12 +2,12 @@
//https://www.5balloons.info/multi-page-step-form-in-laravel-with-validation/ //https://www.5balloons.info/multi-page-step-form-in-laravel-with-validation/
namespace App\Http\Controllers\Publish; namespace App\Http\Controllers\Publish;
use App\Dataset; use App\Models\Dataset;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\License; use App\Models\License;
use App\Models\File; use App\Models\File;
use App\Person; use App\Models\Person;
use App\Project; use App\Models\Project;
use App\Models\Title; use App\Models\Title;
use App\Rules\RdrFiletypes; use App\Rules\RdrFiletypes;
use App\Rules\RdrFilesize; use App\Rules\RdrFilesize;

View File

@ -3,7 +3,7 @@ namespace App\Http\Controllers\Settings\Access;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Role; use App\Models\Role;
use App\User; use App\Models\User;
use Illuminate\Http\Request; use Illuminate\Http\Request;
class UserController extends Controller class UserController extends Controller

View File

@ -3,7 +3,7 @@ namespace App\Http\Controllers\Settings;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\ProjectRequest; use App\Http\Requests\ProjectRequest;
use App\Project; use App\Models\Project;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\View\View; use Illuminate\View\View;

View File

@ -4,7 +4,7 @@ namespace App\Http\Controllers\Settings;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Requests; use App\Http\Requests;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Collection; use App\Models\Collection;
class CollectionController extends Controller class CollectionController extends Controller
{ {

View File

@ -2,9 +2,9 @@
namespace App\Http\Controllers\Settings; namespace App\Http\Controllers\Settings;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Dataset; use App\Models\Dataset;
use App\Project; use App\Models\Project;
use App\License; use App\Models\License;
use App\Models\Title; use App\Models\Title;
use App\Http\Requests\DocumentRequest; use App\Http\Requests\DocumentRequest;
use Illuminate\View\View; use Illuminate\View\View;
@ -33,9 +33,6 @@ class DatasetController extends Controller
} else { } else {
$state = "published"; $state = "published";
} }
$data = $request->all(); $data = $request->all();
if ($searchType == "simple") { if ($searchType == "simple") {

View File

@ -2,8 +2,8 @@
namespace App\Http\Controllers\Settings; namespace App\Http\Controllers\Settings;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\License; use App\Models\License;
use App\Language; use App\Models\Language;
use App\Http\Requests\LicenseRequest; use App\Http\Requests\LicenseRequest;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\View\View; use Illuminate\View\View;

View File

@ -2,7 +2,7 @@
namespace App\Http\Controllers\Settings; namespace App\Http\Controllers\Settings;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Person; use App\Models\Person;
use App\Http\Requests\PersonRequest; use App\Http\Requests\PersonRequest;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\View\View; use Illuminate\View\View;

View File

@ -56,6 +56,7 @@ class Kernel extends HttpKernel
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
// 'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class, // 'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
// 'perm' => \App\Http\Middleware\PermissionMiddleware::class, // 'perm' => \App\Http\Middleware\PermissionMiddleware::class,

View File

@ -1,8 +1,7 @@
<?php <?php
namespace App\Library\Xml; namespace App\Library\Xml;
use App\Library\Util\Searchtypes; use App\Models\Dataset;
use App\Dataset;
/** /**
* Conf short summary. * Conf short summary.

View File

@ -2,6 +2,9 @@
namespace App\Library\Xml; namespace App\Library\Xml;
use App\Models\Title; use App\Models\Title;
use App\Models\License;
use App\Models\Person;
use App\Models\File;
/** /**
* DatasetExtension short summary. * DatasetExtension short summary.
@ -13,7 +16,7 @@ use App\Models\Title;
*/ */
trait DatasetExtension trait DatasetExtension
{ {
protected $_externalFields = array( protected $externalFields = array(
'TitleMain' => array( 'TitleMain' => array(
'model' => Title::class, 'model' => Title::class,
'options' => array('type' => 'main'), 'options' => array('type' => 'main'),
@ -25,13 +28,13 @@ trait DatasetExtension
'fetch' => 'eager' 'fetch' => 'eager'
), ),
'Licence' => array( 'Licence' => array(
'model' => 'App\License', 'model' => License::class,
'through' => 'link_documents_licences', 'through' => 'link_documents_licences',
'relation' => 'licenses', 'relation' => 'licenses',
'fetch' => 'eager' 'fetch' => 'eager'
), ),
'PersonAuthor' => array( 'PersonAuthor' => array(
'model' => 'App\Person', 'model' => Person::class,
'through' => 'link_documents_persons', 'through' => 'link_documents_persons',
'pivot' => array('role' => 'author'), 'pivot' => array('role' => 'author'),
//'sort_order' => array('sort_order' => 'ASC'), // <-- We need a sorted authors list. //'sort_order' => array('sort_order' => 'ASC'), // <-- We need a sorted authors list.
@ -40,7 +43,7 @@ trait DatasetExtension
'fetch' => 'eager' 'fetch' => 'eager'
), ),
'PersonContributor' => array( 'PersonContributor' => array(
'model' => 'App\Person', 'model' => Person::class,
'through' => 'link_documents_persons', 'through' => 'link_documents_persons',
'pivot' => array('role' => 'contributor'), 'pivot' => array('role' => 'contributor'),
// 'sort_order' => array('sort_order' => 'ASC'), // <-- We need a sorted authors list. // 'sort_order' => array('sort_order' => 'ASC'), // <-- We need a sorted authors list.
@ -49,15 +52,15 @@ trait DatasetExtension
'fetch' => 'eager' 'fetch' => 'eager'
), ),
'File' => array( 'File' => array(
'model' => 'App\Models\File', 'model' => File::class,
'relation' => 'files', 'relation' => 'files',
'fetch' => 'eager' 'fetch' => 'eager'
), ),
); );
protected $_internalFields = array(); protected $internalFields = array();
protected $_fields = array(); protected $fields = array();
protected function _initFields() protected function _initFields()
{ {
@ -90,7 +93,7 @@ trait DatasetExtension
$this->addField($field); $this->addField($field);
} }
foreach (array_keys($this->_externalFields) as $fieldname) { foreach (array_keys($this->externalFields) as $fieldname) {
$field = new Field($fieldname); $field = new Field($fieldname);
$field->setMultiplicity('*'); $field->setMultiplicity('*');
$this->addField($field); $this->addField($field);
@ -112,21 +115,21 @@ trait DatasetExtension
/** /**
* Get a list of all fields attached to the model. Filters all fieldnames * Get a list of all fields attached to the model. Filters all fieldnames
* that are defined to be inetrnal in $_internalFields. * that are defined to be inetrnal in $internalFields.
* *
* @see Opus_Model_Abstract::_internalFields * @see Opus_Model_Abstract::internalFields
* @return array List of fields * @return array List of fields
*/ */
public function describe() public function describe()
{ {
return array_diff(array_keys($this->_fields), $this->_internalFields); return array_diff(array_keys($this->fields), $this->internalFields);
} }
public function addField(Field $field) public function addField(Field $field)
{ {
$fieldname = $field->getName(); $fieldname = $field->getName();
if (isset($fieldname, $this->_externalFields[$fieldname])) { if (isset($fieldname, $this->externalFields[$fieldname])) {
$options = $this->_externalFields[$fieldname]; $options = $this->externalFields[$fieldname];
// set ValueModelClass if a through option is given // set ValueModelClass if a through option is given
if (isset($options['model'])) { if (isset($options['model'])) {
@ -139,7 +142,7 @@ trait DatasetExtension
//} //}
} }
$this->_fields[$field->getName()] = $field; $this->fields[$field->getName()] = $field;
$field->setOwningModelClass(get_class($this)); $field->setOwningModelClass(get_class($this));
return $this; return $this;
} }
@ -157,8 +160,8 @@ trait DatasetExtension
*/ */
protected function _getField($name) protected function _getField($name)
{ {
if (isset($this->_fields[$name])) { if (isset($this->fields[$name])) {
return $this->_fields[$name]; return $this->fields[$name];
} else { } else {
return null; return null;
} }
@ -167,11 +170,11 @@ trait DatasetExtension
public function fetchValues() public function fetchValues()
{ {
$this->_initFields(); $this->_initFields();
foreach ($this->_fields as $fieldname => $field) { foreach ($this->fields as $fieldname => $field) {
if (isset($this->_externalFields[$fieldname]) === true) { if (isset($this->externalFields[$fieldname]) === true) {
$fetchmode = 'lazy'; $fetchmode = 'lazy';
if (isset($this->_externalFields[$fieldname]['fetch']) === true) { if (isset($this->externalFields[$fieldname]['fetch']) === true) {
$fetchmode = $this->_externalFields[$fieldname]['fetch']; $fetchmode = $this->externalFields[$fieldname]['fetch'];
} }
if ($fetchmode === 'lazy') { if ($fetchmode === 'lazy') {
@ -210,7 +213,7 @@ trait DatasetExtension
protected function _loadExternal($fieldname) protected function _loadExternal($fieldname)
{ {
$field = $this->_fields[$fieldname]; $field = $this->fields[$fieldname];
$modelclass = $field->getLinkModelClass(); $modelclass = $field->getLinkModelClass();
if (!isset($modelclass)) { if (!isset($modelclass)) {
@ -223,8 +226,8 @@ trait DatasetExtension
$select = $tableclass->query();//->where("document_id", $this->id);; $select = $tableclass->query();//->where("document_id", $this->id);;
// If any declared constraints, add them to query // If any declared constraints, add them to query
if (isset($this->_externalFields[$fieldname]['options'])) { if (isset($this->externalFields[$fieldname]['options'])) {
$options = $this->_externalFields[$fieldname]['options']; $options = $this->externalFields[$fieldname]['options'];
foreach ($options as $column => $value) { foreach ($options as $column => $value) {
$select = $select->where($column, $value); $select = $select->where($column, $value);
} }
@ -236,17 +239,17 @@ trait DatasetExtension
$datasetId = $this->id; $datasetId = $this->id;
$rows = array(); $rows = array();
if (isset($this->_externalFields[$fieldname]['through'])) { if (isset($this->externalFields[$fieldname]['through'])) {
$relation = $this->_externalFields[$fieldname]['relation']; $relation = $this->externalFields[$fieldname]['relation'];
//$rows = $select->datasets //$rows = $select->datasets
////->orderBy('name') ////->orderBy('name')
//->get(); //->get();
//$licenses = $select->with('datasets')->get(); //$licenses = $select->with('datasets')->get();
//$rows = $supplier->datasets; //$rows = $supplier->datasets;
$rows = $this->{$relation}; $rows = $this->{$relation};
//if (isset($this->_externalFields[$fieldname]['pivot'])) //if (isset($this->externalFields[$fieldname]['pivot']))
//{ //{
// $pivArray = $this->_externalFields[$fieldname]['pivot']; // $pivArray = $this->externalFields[$fieldname]['pivot'];
// $rows = $rows->wherePivot('role', $pivArray['role']); // $rows = $rows->wherePivot('role', $pivArray['role']);
//} //}
} else { } else {

View File

@ -1,7 +1,7 @@
<?php <?php
namespace App\Library\Xml; namespace App\Library\Xml;
use App\Dataset; use App\Models\Dataset;
use DOMDocument; use DOMDocument;
/** /**

View File

@ -15,7 +15,7 @@
*/ */
namespace App\Library\Xml; namespace App\Library\Xml;
use App\XmlCache; use App\Models\XmlCache;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class XmlModel class XmlModel
@ -24,19 +24,19 @@ class XmlModel
* Holds current configuration. * Holds current configuration.
* @var Conf * @var Conf
*/ */
private $_config = null; private $config = null;
/** /**
* Holds current xml strategy object. * Holds current xml strategy object.
* @var Strategy * @var Strategy
*/ */
private $_strategy = null; private $strategy = null;
/** /**
* TODO * TODO
* @var XmlCache * @var XmlCache
*/ */
private $_cache = null; private $cache = null;
/** /**
@ -45,9 +45,9 @@ class XmlModel
*/ */
public function __construct() public function __construct()
{ {
$this->_strategy = new Strategy();// Opus_Model_Xml_Version1; $this->strategy = new Strategy();// Opus_Model_Xml_Version1;
$this->_config = new Conf(); $this->config = new Conf();
$this->_strategy->setup($this->_config); $this->strategy->setup($this->config);
} }
/** /**
@ -59,8 +59,8 @@ class XmlModel
*/ */
public function setStrategy(Strategy $strategy) public function setStrategy(Strategy $strategy)
{ {
$this->_strategy = $strategy; $this->strategy = $strategy;
$this->_strategy->setup($this->_config); $this->strategy->setup($this->config);
return $this; return $this;
} }
@ -73,7 +73,7 @@ class XmlModel
*/ */
public function setXmlCache(XmlCache $cache) public function setXmlCache(XmlCache $cache)
{ {
$this->_cache = $cache; $this->cache = $cache;
return $this; return $this;
} }
@ -84,19 +84,19 @@ class XmlModel
*/ */
public function getXmlCache() public function getXmlCache()
{ {
return $this->_cache; return $this->cache;
} }
/** /**
* Set the Model for XML generation. * Set the Model for XML generation.
* *
* @param \App\Dataset $model Model to serialize. * @param \App\Models\Dataset $model Model to serialize.
* *
* @return XmlModel Fluent interface. * @return XmlModel Fluent interface.
*/ */
public function setModel($model) public function setModel($model)
{ {
$this->_config->model = $model; $this->config->model = $model;
return $this; return $this;
} }
@ -107,7 +107,7 @@ class XmlModel
*/ */
public function excludeEmptyFields() public function excludeEmptyFields()
{ {
$this->_config->excludeEmpty = true; $this->config->excludeEmpty = true;
return $this; return $this;
} }
@ -119,7 +119,7 @@ class XmlModel
*/ */
public function getDomDocument() public function getDomDocument()
{ {
$dataset = $this->_config->model; $dataset = $this->config->model;
$domDocument = $this->getDomDocumentFromXmlCache(); $domDocument = $this->getDomDocumentFromXmlCache();
if (!is_null($domDocument)) { if (!is_null($domDocument)) {
@ -127,19 +127,19 @@ class XmlModel
} }
//create xml: //create xml:
$domDocument = $this->_strategy->getDomDocument(); $domDocument = $this->strategy->getDomDocument();
//if caching is not desired, return domDocument //if caching is not desired, return domDocument
if (is_null($this->_cache)) { if (is_null($this->cache)) {
return $domDocument; return $domDocument;
} else { } else {
//create cache relation //create cache relation
$this->_cache->fill(array( $this->cache->fill(array(
'document_id' => $dataset->id, 'document_id' => $dataset->id,
'xml_version' => (int)$this->_strategy->getVersion(), 'xml_version' => (int)$this->strategy->getVersion(),
'server_date_modified' => $dataset->server_date_modified, 'server_date_modified' => $dataset->server_date_modified,
'xml_data' => $domDocument->saveXML() 'xml_data' => $domDocument->saveXML()
)); ));
$this->_cache->save(); $this->cache->save();
Log::debug(__METHOD__ . ' cache refreshed for ' . get_class($dataset) . '#' . $dataset->id); Log::debug(__METHOD__ . ' cache refreshed for ' . get_class($dataset) . '#' . $dataset->id);
return $domDocument; return $domDocument;
@ -155,15 +155,15 @@ class XmlModel
*/ */
private function getDomDocumentFromXmlCache() private function getDomDocumentFromXmlCache()
{ {
$dataset = $this->_config->model; $dataset = $this->config->model;
if (null === $this->_cache) { if (null === $this->cache) {
//$logger->debug(__METHOD__ . ' skipping cache for ' . get_class($model)); //$logger->debug(__METHOD__ . ' skipping cache for ' . get_class($model));
Log::debug(__METHOD__ . ' skipping cache for ' . get_class($dataset)); Log::debug(__METHOD__ . ' skipping cache for ' . get_class($dataset));
return null; return null;
} }
//$cached = $this->_cache->hasValidEntry( //$cached = $this->cache->hasValidEntry(
// $dataset->id, // $dataset->id,
// (int) $this->_strategy->getVersion(), // (int) $this->strategy->getVersion(),
// $dataset->server_date_modified // $dataset->server_date_modified
//); //);

15
app/Models/Collection.php Normal file
View File

@ -0,0 +1,15 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\Dataset;
class Collection extends Model
{
public function documents()
{
return $this->belongsToMany(Dataset::class, 'link_documents_collections', 'collection_id', 'document_id');
}
}

View File

@ -1,10 +1,15 @@
<?php <?php
namespace App; namespace App\Models;
use App\Library\Xml\DatasetExtension; use App\Library\Xml\DatasetExtension;
use Illuminate\Database\Eloquent\Model; use App\Models\Collection;
use App\Models\License;
use App\Models\Project;
use App\Models\Title; use App\Models\Title;
use App\Models\Person;
use App\Models\XmlCache;
use Illuminate\Database\Eloquent\Model;
class Dataset extends Model class Dataset extends Model
{ {
@ -23,7 +28,7 @@ class Dataset extends Model
'creating_corporation', 'creating_corporation',
'project_id', 'project_id',
'embargo_date', 'embargo_date',
'belongs_to_bibliography' 'belongs_to_bibliography',
]; ];
/** /**
* The attributes that should be mutated to dates. * The attributes that should be mutated to dates.
@ -44,17 +49,17 @@ class Dataset extends Model
} }
/** /**
* Get the project that the product belongs to. * Get the project that the dataset belongs to.
*/ */
public function project() public function project()
{ {
return $this->belongsTo(\App\Project::class, 'project_id', 'id'); return $this->belongsTo(Project::class, 'project_id', 'id');
} }
public function collections() public function collections()
{ {
return $this return $this
->belongsToMany(\App\Collection::class, 'link_documents_collections', 'document_id', 'collection_id'); ->belongsToMany(Collection::class, 'link_documents_collections', 'document_id', 'collection_id');
} }
#region [person table] #region [person table]
@ -62,7 +67,7 @@ class Dataset extends Model
//return all persons attached to this film //return all persons attached to this film
public function persons() public function persons()
{ {
return $this->belongsToMany(\App\Person::class, 'link_documents_persons', 'document_id', 'person_id') return $this->belongsToMany(Person::class, 'link_documents_persons', 'document_id', 'person_id')
->withPivot('role'); ->withPivot('role');
} }
@ -74,18 +79,18 @@ class Dataset extends Model
public function authors() public function authors()
{ {
return $this return $this
->belongsToMany(\App\Person::class, 'link_documents_persons', 'document_id', 'person_id') ->belongsToMany(Person::class, 'link_documents_persons', 'document_id', 'person_id')
->wherePivot('role', 'author'); ->wherePivot('role', 'author');
} }
/** /**
* Add author to dataset * Add author to dataset
* *
* @param \App\User $user user to add * @param Person $user user to add
* *
* @return void * @return void
*/ */
public function addAuthor(\App\User $user): void public function addAuthor(Person $user): void
{ {
$this->persons()->save($user, ['role' => 'author']); $this->persons()->save($user, ['role' => 'author']);
} }
@ -98,7 +103,7 @@ class Dataset extends Model
public function contributors() public function contributors()
{ {
return $this return $this
->belongsToMany(\App\Person::class, 'link_documents_persons', 'document_id', 'person_id') ->belongsToMany(Person::class, 'link_documents_persons', 'document_id', 'person_id')
->wherePivot('role', 'contributor'); ->wherePivot('role', 'contributor');
} }
@ -143,7 +148,7 @@ class Dataset extends Model
public function licenses() public function licenses()
{ {
return $this->belongsToMany(\App\License::class, 'link_documents_licences', 'document_id', 'licence_id'); return $this->belongsToMany(License::class, 'link_documents_licences', 'document_id', 'licence_id');
} }
public function files() public function files()
@ -154,11 +159,11 @@ class Dataset extends Model
/** /**
* Get the xml-cache record associated with the dataset. * Get the xml-cache record associated with the dataset.
* *
* @return \App\XmlCache * @return \App\Models\XmlCache
*/ */
public function xmlCache() public function xmlCache()
{ {
return $this->hasOne(\App\XmlCache::class, 'document_id', 'id'); return $this->hasOne(XmlCache::class, 'document_id', 'id');
} }
public function scopeOrderByType($query) public function scopeOrderByType($query)

View File

@ -1,7 +1,7 @@
<?php <?php
namespace App; namespace App\Models;
use App\Dataset; use App\Models\Dataset;
/** /**
* DocumentFinder short summary. * DocumentFinder short summary.
@ -16,7 +16,7 @@ class DatasetFinder
/** /**
* @var \Illuminate\Database\Eloquent\Builder * @var \Illuminate\Database\Eloquent\Builder
*/ */
private $_select = null; private $select = null;
/** /**
* Create new instance of Opus_DocumentList class. The created object * Create new instance of Opus_DocumentList class. The created object
* allows to get custom subsets (or lists) of all existing Opus_Documents. * allows to get custom subsets (or lists) of all existing Opus_Documents.
@ -26,9 +26,9 @@ class DatasetFinder
// $table = Opus_Db_TableGateway::getInstance(self::$_tableGatewayClass); // $table = Opus_Db_TableGateway::getInstance(self::$_tableGatewayClass);
// $this->_db = $table->getAdapter(); // $this->_db = $table->getAdapter();
// $this->_select = $this->_db->select()->from(array('d' => 'documents')); // $this->select = $this->_db->select()->from(array('d' => 'documents'));
$this->_select = Dataset::query(); //>select('name', 'email as user_email') $this->select = Dataset::query(); //>select('name', 'email as user_email')
} }
/** /**
@ -39,8 +39,8 @@ class DatasetFinder
*/ */
public function setServerStateInList($serverStateArray) public function setServerStateInList($serverStateArray)
{ {
$this->_select->whereIn('server_state', $serverStateArray); $this->select->whereIn('server_state', $serverStateArray);
//$this->_select->where('server_state IN (?)', $serverStateArray); //$this->select->where('server_state IN (?)', $serverStateArray);
return $this; return $this;
} }
@ -52,7 +52,7 @@ class DatasetFinder
*/ */
public function setType($type) public function setType($type)
{ {
$this->_select->where('type', $type); $this->select->where('type', $type);
return $this; return $this;
} }
@ -64,8 +64,8 @@ class DatasetFinder
*/ */
public function setServerState($serverState) public function setServerState($serverState)
{ {
//$this->_select->where('server_state', '=', $serverState); //$this->select->where('server_state', '=', $serverState);
$this->_select->where('server_state', 'LIKE', "%".$serverState."%"); $this->select->where('server_state', 'LIKE', "%".$serverState."%");
return $this; return $this;
} }
@ -76,8 +76,8 @@ class DatasetFinder
*/ */
public function groupedTypesPlusCount() public function groupedTypesPlusCount()
{ {
//$this->_select->reset('columns'); //$this->select->reset('columns');
$test = $this->_select $test = $this->select
//->select("type") // "count(DISTINCT id)"); //->select("type") // "count(DISTINCT id)");
->selectRaw('type, count(DISTINCT id) as count') ->selectRaw('type, count(DISTINCT id) as count')
->groupBy('type') ->groupBy('type')
@ -93,7 +93,7 @@ class DatasetFinder
*/ */
public function count() public function count()
{ {
$this->_select->count(); $this->select->count();
} }
/** /**
@ -107,6 +107,6 @@ class DatasetFinder
public function ids() public function ids()
{ {
//return array_unique($this->_db->fetchCol($this->getSelectIds())); //return array_unique($this->_db->fetchCol($this->getSelectIds()));
return $this->_select->pluck('id')->toArray(); return $this->select->pluck('id')->toArray();
} }
} }

View File

@ -2,7 +2,7 @@
namespace App\Models; namespace App\Models;
use App\Dataset; use App\Models\Dataset;
use App\Models\HashValue; use App\Models\HashValue;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;

View File

@ -1,5 +1,5 @@
<?php <?php
namespace App; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;

View File

@ -1,7 +1,8 @@
<?php <?php
namespace App; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use App\Models\Dataset;
class License extends Model class License extends Model
{ {
@ -19,11 +20,11 @@ class License extends Model
'mime_type', 'mime_type',
'name_long', 'name_long',
'pod_allowed', 'pod_allowed',
'sort_order' 'sort_order',
]; ];
public function datasets() public function datasets()
{ {
return $this->belongsToMany(\App\Dataset::class, 'link_documents_licences', 'licence_id', 'document_id'); return $this->belongsToMany(Dataset::class, 'link_documents_licences', 'licence_id', 'document_id');
} }
} }

View File

@ -3,7 +3,7 @@
namespace App\Models; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use App\User; use App\Models\User;
use App\Models\ModelTrait; use App\Models\ModelTrait;
class Page extends Model class Page extends Model
@ -62,7 +62,8 @@ class Page extends Model
*/ */
public function getViewButtonAttribute() public function getViewButtonAttribute()
{ {
return '<a target="_blank" href="'. route('frontend.pages.show', $this->page_slug) .'" class="btn btn-flat btn-default"> return '<a target="_blank" href="
'. route('frontend.pages.show', $this->page_slug) .' " class="btn btn-flat btn-default">
<i data-toggle="tooltip" data-placement="top" title="View Page" class="fa fa-eye"></i> <i data-toggle="tooltip" data-placement="top" title="View Page" class="fa fa-eye"></i>
</a>'; </a>';
} }

View File

@ -1,6 +1,7 @@
<?php <?php
namespace App; namespace App\Models;
use App\Models\Dataset;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
class Person extends Model class Person extends Model
@ -12,28 +13,29 @@ class Person extends Model
'first_name', 'first_name',
'email', 'email',
'identifier_orcid', 'identifier_orcid',
'status' 'status',
]; ];
protected $table = 'persons'; protected $table = 'persons';
public $timestamps = false; public $timestamps = false;
protected $appends = ['full_name'];
public function documents() public function documents()
{ {
return $this->belongsToMany(\App\Dataset::class, 'link_documents_persons', 'person_id', 'document_id') return $this->belongsToMany(Dataset::class, 'link_documents_persons', 'person_id', 'document_id')
->withPivot('role'); ->withPivot('role');
} }
// public function scopeNotLimit($query) // public function scopeNotLimit($query)
// { // {
// return $query->where('borrow', '<', 3); // return $query->where('borrow', '<', 3);
// } // }
/** /**
* Get the user's full name. * Get the user's full name.
* * see https://laravel.com/docs/5.6/eloquent-serialization
* @return string * @return string
*/ */
public function getFullName() public function getFullNameAttribute()
{ {
return $this->first_name . " " . $this->last_name; return $this->first_name . " " . $this->last_name;
} }

View File

@ -1,7 +1,8 @@
<?php <?php
namespace App; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use App\Models\Dataset;
class Project extends Model class Project extends Model
{ {
@ -18,7 +19,7 @@ class Project extends Model
public function documents() public function documents()
{ {
//model, foreign key on the Document model is project_id, local id of category //model, foreign key on the Document model is project_id, local id of category
return $this->hasMany(\App\Dataset::class, 'project_id', 'id'); return $this->hasMany(Dataset::class, 'project_id', 'id');
} }
// public function books() // public function books()

View File

@ -4,6 +4,7 @@ namespace App\Models;
//use App\Library\Xml\DatasetExtension; //use App\Library\Xml\DatasetExtension;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use App\Models\Dataset;
class Title extends Model class Title extends Model
{ {
@ -16,6 +17,6 @@ class Title extends Model
public function dataset() public function dataset()
{ {
return $this->belongsTo(\App\Dataset::class, 'document_id', 'id'); return $this->belongsTo(Dataset::class, 'document_id', 'id');
} }
} }

2
app/User.php → app/Models/User.php Executable file → Normal file
View File

@ -1,5 +1,5 @@
<?php <?php
namespace App; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notifiable;

View File

@ -1,8 +1,9 @@
<?php <?php
namespace App; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use App\Models\Dataset;
class XmlCache extends Model class XmlCache extends Model
{ {
@ -36,7 +37,7 @@ class XmlCache extends Model
*/ */
public function dataset() public function dataset()
{ {
return $this->belongsTo(\App\Dataset::class, 'document_id', 'id'); return $this->belongsTo(Dataset::class, 'document_id', 'id');
} }
/** /**

View File

@ -1,7 +1,7 @@
<?php <?php
namespace App\Services; namespace App\Services;
use App\User; use App\Models\User;
use Validator; use Validator;
use Illuminate\Contracts\Auth\Registrar as RegistrarContract; use Illuminate\Contracts\Auth\Registrar as RegistrarContract;

View File

@ -27,8 +27,7 @@
"autoload": { "autoload": {
"classmap": [ "classmap": [
"database/seeds", "database/seeds",
"database/factories", "database/factories"
"database"
], ],
"psr-4": { "psr-4": {
"App\\": "app/" "App\\": "app/"
@ -65,6 +64,7 @@
"role": "Developer" "role": "Developer"
} }
], ],
"minimum-stability": "dev",
"prefer-stable": true, "prefer-stable": true,
"homepage": "https://www.geologie.ac.at/" "homepage": "https://www.geologie.ac.at/"
} }

14
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "45de841e5697551ae24e4065b9afb6c4", "content-hash": "01c12d1633f3bbbb6ddbff87d4516b4f",
"packages": [ "packages": [
{ {
"name": "davejamesmiller/laravel-breadcrumbs", "name": "davejamesmiller/laravel-breadcrumbs",
@ -3409,16 +3409,16 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "6.5.12", "version": "6.5.13",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "24da433d7384824d65ea93fbb462e2f31bbb494e" "reference": "0973426fb012359b2f18d3bd1e90ef1172839693"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/24da433d7384824d65ea93fbb462e2f31bbb494e", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0973426fb012359b2f18d3bd1e90ef1172839693",
"reference": "24da433d7384824d65ea93fbb462e2f31bbb494e", "reference": "0973426fb012359b2f18d3bd1e90ef1172839693",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3489,7 +3489,7 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2018-08-22T06:32:48+00:00" "time": "2018-09-08T15:10:43+00:00"
}, },
{ {
"name": "phpunit/phpunit-mock-objects", "name": "phpunit/phpunit-mock-objects",
@ -4252,7 +4252,7 @@
} }
], ],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "dev",
"stability-flags": [], "stability-flags": [],
"prefer-stable": true, "prefer-stable": true,
"prefer-lowest": false, "prefer-lowest": false,

View File

@ -67,7 +67,7 @@ return [
'providers' => [ 'providers' => [
'users' => [ 'users' => [
'driver' => 'eloquent', 'driver' => 'eloquent',
'model' => App\User::class, 'model' => App\Models\User::class,
], ],
// 'users' => [ // 'users' => [

View File

@ -51,7 +51,7 @@ return [
| Update the User if it is in a different namespace. | Update the User if it is in a different namespace.
| |
*/ */
'user' => 'App\User', 'user' => 'App\Models\User',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

View File

@ -30,7 +30,7 @@ return [
], ],
'stripe' => [ 'stripe' => [
'model' => 'App\User', 'model' => 'App\Models\User',
'secret' => '', 'secret' => '',
], ],

File diff suppressed because one or more lines are too long

View File

@ -1,9 +1,10 @@
// MyVuetable.vue // MyVuetable.vue
<!-- :fields="['name', 'email', 'birthdate']" -->
// "https://vuetable.ratiw.net/api/users"
<template> <template>
<vuetable ref="vuetable" <vuetable ref="vuetable"
api-url="https://vuetable.ratiw.net/api/users" api-url="/api/persons"
:fields="['name', 'email', 'birthdate']" v-bind:fields="fields" pagination-path=""
></vuetable> ></vuetable>
</template> </template>
@ -13,6 +14,61 @@ import Vuetable from "vuetable-2/src/components/Vuetable";
export default { export default {
components: { components: {
Vuetable Vuetable
},
data() {
return {
fields: [
{
name: "full_name",
// sortField: "name"
},
{
name: "email",
// sortField: "email"
},
{
name: "date_of_birth",
// sortField: "birthdate",
// titleClass: "text-center",
// dataClass: "text-center",
// callback: "formatDate|DD-MM-YYYY"
},
{
name: "__component:custom-actions",
title: "Actions",
titleClass: "text-center",
dataClass: "text-center"
}
],
css: {
table: {
tableClass: "table table-bordered table-striped table-hover",
ascendingIcon: "glyphicon glyphicon-chevron-up",
descendingIcon: "glyphicon glyphicon-chevron-down"
},
pagination: {
wrapperClass: "pagination",
activeClass: "active",
disabledClass: "disabled",
pageClass: "page",
linkClass: "link",
icons: {
first: "",
prev: "",
next: "",
last: ""
}
},
icons: {
first: "glyphicon glyphicon-step-backward",
prev: "glyphicon glyphicon-chevron-left",
next: "glyphicon glyphicon-chevron-right",
last: "glyphicon glyphicon-step-forward"
}
},
sortOrder: [{ field: "email", sortField: "email", direction: "asc" }],
moreParams: {}
};
} }
}; };
</script> </script>

View File

@ -4,7 +4,7 @@ return [
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Pagination Language Lines | Doctypes Language Lines
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| The following language lines are used by the paginator library to build | The following language lines are used by the paginator library to build

View File

@ -3,7 +3,7 @@
@section('content') @section('content')
<div class="header"> <div class="header">
<h3 class="header-title"> <h3 class="header-title">
Edit {{ $person->getFullName() }} Edit {{ $person->full_name }}
</h3> </h3>
</div> </div>

View File

@ -2,6 +2,7 @@
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
use App\Models\Person;
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -18,4 +19,45 @@ Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user(); return $request->user();
}); });
Route::get('/oai', 'Oai\RequestController@identify'); Route::get('/oai', 'Oai\RequestController@identify');
Route::get('/api/persons', function () {
$request = request();
$query = Person::query();//->with('group');
// handle sort option
//if (request()->has('sort')) {
if (null !== ($request->input('sort'))) {
// handle multisort
$sorts = explode(',', request()->sort);
foreach ($sorts as $sort) {
list($sortCol, $sortDir) = explode('|', $sort);
$query = $query->orderBy($sortCol, $sortDir);
}
} else {
$query = $query->orderBy('id', 'asc');
}
if ($request->exists('filter')) {
$query->where(function ($q) use ($request) {
$value = "%{$request->filter}%";
$q->where('name', 'like', $value)
// ->orWhere('nickname', 'like', $value)
->orWhere('email', 'like', $value);
});
}
$perPage = request()->has('per_page') ? (int) request()->per_page : null;
// $pagination = $query->with('address')->paginate($perPage);
$pagination = $query->paginate($perPage);
$pagination->appends([
'sort' => request()->sort,
'filter' => request()->filter,
'per_page' => request()->per_page
]);
// The headers 'Access-Control-Allow-Origin' and 'Access-Control-Allow-Methods'
// are to allow you to call this from any domain (see CORS for more info).
// This is for local testing only. You should not do this in production server,
// unless you know what it means.
return response()
->json($pagination)
->header('Access-Control-Allow-Origin', '*')
->header('Access-Control-Allow-Methods', 'GET');
});

View File

@ -16,6 +16,7 @@ use Illuminate\Support\Facades\Route;
Route::get('/oai', ['as' => 'oai', 'uses' => 'Oai\RequestController@index']); Route::get('/oai', ['as' => 'oai', 'uses' => 'Oai\RequestController@index']);
//=================================================publish dataasets================================================
Route::group( Route::group(
[ [
'namespace' => 'Publish', 'namespace' => 'Publish',
@ -197,6 +198,9 @@ Route::group(['middleware' => ['permission:settings']], function () {
*/ */
Route::group(['namespace' => 'Frontend', 'as' => 'frontend.'], function () { Route::group(['namespace' => 'Frontend', 'as' => 'frontend.'], function () {
// includeRouteFiles(__DIR__.'/Frontend/'); // includeRouteFiles(__DIR__.'/Frontend/');
Route::get('/test', [
'as' => 'home.index', 'uses' => 'HomeController@test',
]);
Route::get('/', [ Route::get('/', [
'as' => 'home.index', 'uses' => 'HomeController@index', 'as' => 'home.index', 'uses' => 'HomeController@index',
]); ]);
@ -217,7 +221,7 @@ Route::group(['namespace' => 'Frontend', 'as' => 'frontend.'], function () {
Route::get('sitelinks', [ Route::get('sitelinks', [
'as' => 'sitelinks.index', 'uses' => 'SitelinkController@index', 'as' => 'sitelinks.index', 'uses' => 'SitelinkController@index',
]); ]);
Route::get('sitelinks/list/{year}', 'SitelinkController@list')->name('sitelinks.list'); Route::get('sitelinks/list/{year}', 'SitelinkController@listDocs')->name('sitelinks.list');
Route::get('/dataset', [ Route::get('/dataset', [
'as' => 'datasets', 'uses' => 'PagesController@datasets', 'as' => 'datasets', 'uses' => 'PagesController@datasets',