add publish module
This commit is contained in:
parent
100f6db9a6
commit
ffbbc04206
93 changed files with 8150 additions and 10228 deletions
69
app/Models/File.php
Normal file
69
app/Models/File.php
Normal file
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Dataset;
|
||||
use App\Models\HashValue;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class File extends Model
|
||||
{
|
||||
protected $table = 'document_files';
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = ['path_name', 'file_size', 'mime_type', 'label', 'sort_order'];
|
||||
|
||||
public function dataset()
|
||||
{
|
||||
return $this->belongsTo(Dataset::class, 'document_id', 'id');
|
||||
}
|
||||
|
||||
public function hashvalues()
|
||||
{
|
||||
return $this->hasMany(HashValue::class, 'file_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create hash value model objects from original file.
|
||||
*
|
||||
* TODO throws Exception in case hash computation is not possible
|
||||
* (e.g., if referenced file is missing in file system)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function createHashValues()
|
||||
{
|
||||
$hashtypes = array('md5', 'sha512');
|
||||
|
||||
foreach ($hashtypes as $type) {
|
||||
$hash = new HashValue();
|
||||
$hash->type = $type;
|
||||
$hashString = $this->getRealHash($type);
|
||||
$hash->value = $hashString;
|
||||
$this->hashvalues()->save($hash);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hash value of the file
|
||||
*
|
||||
* @param string $type Type of the hash value, @see hash_file();
|
||||
* @return string hash value
|
||||
*/
|
||||
private function getRealHash($type)
|
||||
{
|
||||
$hash = @hash_file($type, $this->getPath());
|
||||
if (empty($hash)) {
|
||||
throw new \Exception("Empty HASH for file '" . $this->getPath() . "'");
|
||||
}
|
||||
return $hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get full path of destination file.
|
||||
*/
|
||||
private function getPath()
|
||||
{
|
||||
return storage_path('app/public/' . $this->path_name);
|
||||
}
|
||||
}
|
17
app/Models/HashValue.php
Normal file
17
app/Models/HashValue.php
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\File;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class HashValue extends Model
|
||||
{
|
||||
protected $table = 'file_hashvalues';
|
||||
public $timestamps = false;
|
||||
|
||||
public function file()
|
||||
{
|
||||
return $this->belongsTo(File::class, 'file_id', 'id');
|
||||
}
|
||||
}
|
10
app/Models/Permission.php
Normal file
10
app/Models/Permission.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Zizaco\Entrust\EntrustPermission;
|
||||
|
||||
class Permission extends EntrustPermission
|
||||
{
|
||||
//
|
||||
}
|
15
app/Models/Role.php
Normal file
15
app/Models/Role.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Zizaco\Entrust\EntrustRole;
|
||||
|
||||
class Role extends EntrustRole
|
||||
{
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['name', 'description'];
|
||||
}
|
21
app/Models/Title.php
Normal file
21
app/Models/Title.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
//use App\Library\Xml\DatasetExtension;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Title extends Model
|
||||
{
|
||||
protected $table = 'document_title_abstracts';
|
||||
public $timestamps = false;
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
];
|
||||
|
||||
public function dataset()
|
||||
{
|
||||
return $this->belongsTo(\App\Dataset::class, 'document_id', 'id');
|
||||
}
|
||||
}
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue