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