Files
UNIT3D-Community-Edition/app/Models/TorrentFile.php
2019-02-22 03:22:57 +00:00

57 lines
1.1 KiB
PHP
Executable File

<?php
/**
* NOTICE OF LICENSE.
*
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D
*
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
* @author HDVinnie
*/
namespace App\Models;
use App\Helpers\StringHelper;
use Illuminate\Database\Eloquent\Model;
class TorrentFile extends Model
{
/**
* Indicates If The Model Should Be Timestamped.
*
* @var bool
*/
public $timestamps = false;
/**
* The Database Table Used By The Model.
*
* @var string
*/
protected $table = 'files';
/**
* Belongs To A Torrent.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function torrent()
{
return $this->belongsTo(Torrent::class);
}
/**
* Return Size In Human Format.
*
* @return string
*/
public function getSize($bytes = null, $precision = 2)
{
$bytes = $this->size;
return StringHelper::formatBytes($bytes, 2);
}
}