mein-sterntours/app/Repositories/CMSFileRepository.php
2020-05-28 19:03:42 +02:00

54 lines
No EOL
1.5 KiB
PHP

<?php
namespace App\Repositories;
use App\Models\CMSContent;
use Response;
class CMSFileRepository extends FileRepository {
protected $identifier;
protected $data;
public function __construct($model){
parent::__construct();
$this->model = $model;
}
public function save(){
$file_data = [
'identifier' => $this->identifier,
'filename' => $this->allowed_filename,
'dir' => $this->dir,
'original_name' => $this->originalName,
'ext' => $this->extension,
'mine' => $this->mine,
'size' => $this->size
];
$data = [
"name" => $this->originalName,
"field" => "file",
"identifier" => $this->data['identifier'],
"object" => $file_data, //\GuzzleHttp\json_encode($file_data),
];
$this->model = CMSContent::create($data);
//store in cms old Datebase
\App\Models\Sym\CmsContent::create($data);
}
public function response(){
return Response::json([
'error' => false,
'filename' => $this->allowed_filename,
'file_id' => $this->model->id,
'file_data' => $this->extension,
'file_icon' => $this->model->getIconExt(),
'file_format_bytes' => $this->model->formatBytes(),
'file_url' => $this->model->getURL(),
'redirect' => '',
'code' => 200
], 200);
}
}