2014-05-14 13:24:20 +00: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';
|
|
|
|
|
|
2015-02-22 03:04:07 +00:00
|
|
|
/**
|
|
|
|
|
* If working with local storage, determine the absolute local path.
|
|
|
|
|
*/
|
|
|
|
|
protected function getLocalRootPath()
|
|
|
|
|
{
|
|
|
|
|
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.
|
|
|
|
|
*/
|
2015-02-22 03:04:07 +00:00
|
|
|
public function getPublicPath()
|
2014-05-14 13:24:20 +00:00
|
|
|
{
|
2015-02-23 08:55:41 +00:00
|
|
|
$uploadsPath = Config::get('cms.storage.uploads.path', '/storage/app/uploads');
|
2015-02-17 09:58:38 +00:00
|
|
|
|
|
|
|
|
if (!preg_match("/(\/\/|http|https)/", $uploadsPath)) {
|
|
|
|
|
$uploadsPath = Request::getBasePath() . $uploadsPath;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-18 09:58:50 +00:00
|
|
|
if ($this->isPublic()) {
|
2015-02-17 09:58:38 +00:00
|
|
|
return $uploadsPath . '/public/';
|
2014-11-01 01:00:45 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2015-02-17 09:58:38 +00:00
|
|
|
return $uploadsPath . '/protected/';
|
2014-10-18 09:58:50 +00:00
|
|
|
}
|
2014-05-14 13:24:20 +00:00
|
|
|
}
|
|
|
|
|
}
|