Preview: File.php
Size: 1.66 KB
/var/www/multi-event-cfp.bitkit.dk/httpdocs/app/Models/File.php
<?php
namespace App\Models;
use App\Support\Entity;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Crypt;
/**
* @property mixed extension
* @property mixed|string filepath
* @property mixed|string public_path
* @property mixed|string thumbnail_path
* @property mixed id
* @property mixed|string save_name
* @property mixed filename
* @property boolean public
*/
class File extends Model
{
use HasFactory;
protected $fillable = [
'model_id',
'model',
'filename',
'filepath',
'type',
'extension',
'context',
'public',
];
public function getFileObject($object = null)
{
if ($object) {
$object->filename = $this->filename;
$object->filepath = $this->filepath;
$object->extension = $this->extension;
$object->file_id = $this->id;
$object->public_path = $this->public_path;
$object->save_name = $this->save_name;
$object->value = $this->public_path ? $this->public_path . "?v=" . md5(Carbon::now()) : null;
} else {
$object = new Entity([
'filename' => $this->filename,
'filepath' => $this->filepath,
'extension' => $this->extension,
'file_id' => $this->id,
'public_path' => $this->public_path,
'save_name' => $this->save_name,
'value' => $this->public_path ? $this->public_path . "?v=" . md5(Carbon::now()) : null
]);
}
return $object;
}
}
Directory Contents
Dirs: 0 × Files: 26