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';
|
|
|
|
|
|
|
|
//
|
|
|
|
// Configuration
|
|
|
|
//
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define the storage path, override this method to define.
|
|
|
|
*/
|
|
|
|
public function getStorageDirectory()
|
|
|
|
{
|
|
|
|
$uploadsDir = Config::get('cms.uploadsDir');
|
2014-10-18 11:58:50 +02:00
|
|
|
if ($this->isPublic()) {
|
2014-05-14 23:24:20 +10:00
|
|
|
return base_path() . $uploadsDir . '/public/';
|
2014-11-01 12:00:45 +11:00
|
|
|
}
|
|
|
|
else {
|
2014-05-14 23:24:20 +10:00
|
|
|
return base_path() . $uploadsDir . '/protected/';
|
2014-10-18 11:58:50 +02:00
|
|
|
}
|
2014-05-14 23:24:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define the public address for the storage path.
|
|
|
|
*/
|
|
|
|
public function getPublicDirectory()
|
|
|
|
{
|
|
|
|
$uploadsDir = Config::get('cms.uploadsDir');
|
2014-10-18 11:58:50 +02:00
|
|
|
if ($this->isPublic()) {
|
2014-06-26 20:37:55 +10:00
|
|
|
return Request::getBasePath() . $uploadsDir . '/public/';
|
2014-11-01 12:00:45 +11:00
|
|
|
}
|
|
|
|
else {
|
2014-06-26 20:37:55 +10:00
|
|
|
return Request::getBasePath() . $uploadsDir . '/protected/';
|
2014-10-18 11:58:50 +02:00
|
|
|
}
|
2014-05-14 23:24:20 +10:00
|
|
|
}
|
|
|
|
}
|