mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
- Not sure how this was not fixed sooner, since there is no easy way to obtain a full qualified URL from a system file. - If a CDN is used this method will return a URL. - The asset combiner returns a FQ URL as well, although it didn't always, perhaps this is a relic from that time that was never retrofitted.
60 lines
1.3 KiB
PHP
60 lines
1.3 KiB
PHP
<?php namespace System\Models;
|
|
|
|
use Url;
|
|
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()
|
|
{
|
|
return Config::get('filesystems.disks.local.root', storage_path('app'));
|
|
}
|
|
|
|
/**
|
|
* Define the public address for the storage path.
|
|
*/
|
|
public function getPublicPath()
|
|
{
|
|
$uploadsPath = Config::get('cms.storage.uploads.path', '/storage/app/uploads');
|
|
|
|
if ($this->isPublic()) {
|
|
$uploadsPath .= '/public';
|
|
}
|
|
else {
|
|
$uploadsPath .= '/protected';
|
|
}
|
|
|
|
return Url::asset($uploadsPath) . '/';
|
|
}
|
|
|
|
/**
|
|
* 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/';
|
|
}
|
|
}
|
|
}
|