ORIENT/modules/system/models/File.php

60 lines
1.3 KiB
PHP
Raw Normal View History

2014-05-14 13:24:20 +00:00
<?php namespace System\Models;
use Url;
2014-05-14 13:24:20 +00:00
use Config;
use October\Rain\Database\Attach\File as FileBase;
/**
* File attachment model
*
* @package october\system
* @author Alexey Bobkov, Samuel Georges
*/
class File extends FileBase
{
/**
* @var string The database table used by the model.
*/
protected $table = 'system_files';
/**
* If working with local storage, determine the absolute local path.
*/
protected function getLocalRootPath()
{
2016-01-15 09:07:39 +00:00
return Config::get('filesystems.disks.local.root', storage_path('app'));
}
2014-05-14 13:24:20 +00:00
/**
* Define the public address for the storage path.
*/
public function getPublicPath()
2014-05-14 13:24:20 +00:00
{
$uploadsPath = Config::get('cms.storage.uploads.path', '/storage/app/uploads');
2014-10-18 09:58:50 +00:00
if ($this->isPublic()) {
$uploadsPath .= '/public';
}
else {
$uploadsPath .= '/protected';
2014-10-18 09:58:50 +00:00
}
return Url::asset($uploadsPath) . '/';
2014-05-14 13:24:20 +00:00
}
/**
* Define the internal storage path.
*/
public function getStorageDirectory()
{
$uploadsFolder = Config::get('cms.storage.uploads.folder');
if ($this->isPublic()) {
return $uploadsFolder . '/public/';
}
else {
return $uploadsFolder . '/protected/';
}
}
2014-05-14 13:24:20 +00:00
}