mein-sterntours/app/Repositories/LeadFileRepository.php
2021-05-11 17:07:20 +02:00

50 lines
No EOL
1.3 KiB
PHP

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