62 lines
1.4 KiB
PHP
Raw Normal View History

2014-05-14 23:24:20 +10:00
<?php namespace System\Models;
use Config;
use Request;
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 10:07:39 +01:00
return Config::get('filesystems.disks.local.root', storage_path('app'));
}
2014-05-14 23:24:20 +10:00
/**
* Define the public address for the storage path.
*/
public function getPublicPath()
2014-05-14 23:24:20 +10:00
{
$uploadsPath = Config::get('cms.storage.uploads.path', '/storage/app/uploads');
2016-07-16 15:34:20 +10:00
if (!starts_with($uploadsPath, ['//', 'http://', 'https://'])) {
$uploadsPath = Request::getBasePath() . $uploadsPath;
}
2014-10-18 11:58:50 +02:00
if ($this->isPublic()) {
return $uploadsPath . '/public/';
}
else {
return $uploadsPath . '/protected/';
2014-10-18 11:58:50 +02:00
}
2014-05-14 23:24:20 +10: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 23:24:20 +10:00
}