mein-sterntours/app/Repositories/BookingFileRepository.php
2020-04-17 15:51:22 +02:00

52 lines
No EOL
1.3 KiB
PHP

<?php
namespace App\Repositories;
use App\Models\BookingFile;
use Response;
class BookingFileRepository extends FileRepository {
protected $booking_file;
protected $booking_id;
protected $identifier;
public function __construct(BookingFile $model){
parent::__construct();
$this->model = $model;
}
public function save(){
$this->booking_file = BookingFile::create([
'booking_id' => $this->booking_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->booking_file->id,
'file_data' => $this->extension,
'file_icon' => $this->booking_file->getIconExt(),
'file_format_bytes' => $this->booking_file->formatBytes(),
'file_url' => $this->booking_file->getURL(),
'redirect' => '',
'code' => 200
], 200);
}
}