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

51 lines
No EOL
1.3 KiB
PHP

<?php
namespace App\Repositories;
use App\Models\GeneralFile;
use Response;
class GeneralFileRepository extends FileRepository {
protected $general_file;
protected $travel_country_id;
protected $identifier;
public function __construct(GeneralFile $model){
parent::__construct();
$this->model = $model;
}
public function save(){
$this->general_file = GeneralFile::create([
'travel_country_id' => $this->travel_country_id,
'identifier' => $this->identifier,
'filename' => $this->allowed_filename,
'dir' => $this->dir,
'original_name' => $this->originalName,
'ext' => $this->extension,
'mine' => $this->mine,
'size' => $this->size
]);
}
public function response(){
return Response::json([
'error' => false,
'filename' => $this->allowed_filename,
'file_id' =>$this->general_file->id,
'file_data' => $this->extension,
'file_icon' => $this->general_file->getIconExt(),
'file_format_bytes' => $this->general_file->formatBytes(),
'file_url' => $this->general_file->getURL(),
'redirect' => $this->redirect,
'code' => 200
], 200);
}
}