Upload Files Booking, Mails, Attachments,
This commit is contained in:
parent
5daea268f7
commit
68b9d1ff88
92 changed files with 2837 additions and 1778 deletions
|
|
@ -4,7 +4,9 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Models\Booking;
|
||||
use App\Models\BookingDraftItem;
|
||||
use App\Models\BookingFile;
|
||||
use App\Models\Customer;
|
||||
use App\Repositories\BookingFileRepository;
|
||||
use App\Repositories\BookingRepository;
|
||||
use App\Repositories\CustomerMailRepository;
|
||||
use App\Repositories\DraftRepository;
|
||||
|
|
@ -43,6 +45,7 @@ class BookingController extends Controller
|
|||
$data = [
|
||||
'booking' => $booking,
|
||||
'id' => $id,
|
||||
|
||||
];
|
||||
return view('booking.detail', $data);
|
||||
|
||||
|
|
@ -186,17 +189,35 @@ class BookingController extends Controller
|
|||
public function loadModal(){
|
||||
$data = Request::all();
|
||||
$ret = "";
|
||||
if(Request::ajax()){
|
||||
$data['customers'] = [];
|
||||
if($data['action'] === "new-customer-mail" && isset($data['booking_id']) && $booking = Booking::find($data['booking_id'])){
|
||||
$tmp = [];
|
||||
$tmp['email'] = $booking->customer ? $booking->customer->email : "";
|
||||
$tmp['name'] = $booking->customer ? $booking->customer->firstname." ".$booking->customer->name." | " : "- | ";
|
||||
$tmp['name'] .= $booking->travel_country_id ? $booking->travel_country->name." | " : "- | ";
|
||||
$tmp['name'] .= $booking->travelagenda_id ? $booking->travel_agenda->name."" : "-";
|
||||
$data['customers'][$booking->id] = $tmp;
|
||||
if(Request::ajax()) {
|
||||
if ($data['action'] === "new-customer-mail" || $data['action'] === "reply-customer-mail" || $data['action'] === "show-customer-mail" || $data['action'] === "edit-customer-mail"){
|
||||
$data['customers'] = [];
|
||||
if ($data['action'] === "new-customer-mail" && isset($data['booking_id']) && $booking = Booking::find($data['booking_id'])) {
|
||||
$tmp = [];
|
||||
$tmp['email'] = $booking->customer ? $booking->customer->email : "";
|
||||
$tmp['name'] = $booking->customer ? $booking->customer->firstname . " " . $booking->customer->name . " | " : "- | ";
|
||||
$tmp['name'] .= $booking->travel_country_id ? $booking->travel_country->name . " | " : "- | ";
|
||||
$tmp['name'] .= $booking->travelagenda_id ? $booking->travel_agenda->name . "" : "-";
|
||||
$data['customers'][$booking->id] = $tmp;
|
||||
}
|
||||
$ret = CustomerMailRepository::loadModal($data);
|
||||
}
|
||||
|
||||
|
||||
if($data['action'] === "modal-upload-booking-file") {
|
||||
$ret = view("booking.upload_modal", compact('data'))->render();
|
||||
}
|
||||
|
||||
if($data['action'] === "upload-booking-file"){
|
||||
if($data['booking_id']){
|
||||
$bookingFileRepo = new BookingFileRepository(new BookingFile());
|
||||
$bookingFileRepo->_set('disk', 'booking');
|
||||
$bookingFileRepo->_set('booking_id', $data['booking_id']);
|
||||
$bookingFileRepo->_set('dir', '/files/'.date('Y/m').'/');
|
||||
$bookingFileRepo->_set('identifier', 'booking');
|
||||
return $bookingFileRepo->uploadFile(Request::all());
|
||||
}
|
||||
}
|
||||
$ret = CustomerMailRepository::loadModal($data);
|
||||
}
|
||||
return response()->json(['response' => $data, 'html'=>$ret]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,20 +5,16 @@ namespace App\Http\Controllers\CMS;
|
|||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\CMSContent;
|
||||
use App\Repositories\CMSFileRepository;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
|
||||
class CMSContentController extends Controller
|
||||
{
|
||||
|
||||
/*
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -28,13 +24,25 @@ class CMSContentController extends Controller
|
|||
'contents' => CMSContent::all()->sortByDesc('id')
|
||||
];
|
||||
return view('cms.content.all.index', $data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function store()
|
||||
{
|
||||
$data = Request::all();
|
||||
|
||||
if(Request::ajax()) {
|
||||
//upload file
|
||||
if($data['file']){
|
||||
$cmsFileRepo = new CMSFileRepository(new CMSContent());
|
||||
$cmsFileRepo->_set('disk', 'public');
|
||||
$cmsFileRepo->_set('dir', '/cms_files/'.date('Y/m').'/');
|
||||
$cmsFileRepo->_set('identifier', 'cms_file');
|
||||
return $cmsFileRepo->uploadFile(Request::all());
|
||||
}
|
||||
return response()->json(['response' => $data, 'html'=>""]);
|
||||
|
||||
}
|
||||
$rules = array(
|
||||
'name' => 'required',
|
||||
'field' => 'required',
|
||||
|
|
@ -50,7 +58,6 @@ class CMSContentController extends Controller
|
|||
//store in cms old Datebase
|
||||
\App\Models\Sym\CmsContent::create($data);
|
||||
}else{
|
||||
|
||||
$model = CMSContent::find($data['id']);
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
|
|
@ -65,7 +72,7 @@ class CMSContentController extends Controller
|
|||
}
|
||||
|
||||
|
||||
public function loadModal()
|
||||
public function loadModal()
|
||||
{
|
||||
if(Request::ajax()){
|
||||
$data = Request::all();
|
||||
|
|
@ -79,16 +86,19 @@ class CMSContentController extends Controller
|
|||
}
|
||||
$returnHTML = view("cms.content.all.modal", compact('data','value') )->render();
|
||||
}
|
||||
|
||||
}
|
||||
return response()->json(['response' => $data, 'html'=>$returnHTML]);
|
||||
}
|
||||
}
|
||||
|
||||
//public
|
||||
|
||||
|
||||
public function delete($id){
|
||||
$content = CMSContent::findOrFail($id);
|
||||
if($content->isFile()){
|
||||
$content->deleteFile();
|
||||
}
|
||||
$content->delete();
|
||||
\Session()->flash('alert-success', __('Content gelöscht'));
|
||||
return redirect(route('cms_content_all'));
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ class CustomerFileController extends Controller
|
|||
|
||||
public function __construct(CustomerFileRepository $customerFileRepo)
|
||||
{
|
||||
$this->middleware('admin');
|
||||
$this->customerFileRepo = $customerFileRepo;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use App\Models\CustomerFile;
|
|||
use App\Models\CustomerMail;
|
||||
use App\Repositories\CustomerMailRepository;
|
||||
use App\Repositories\CustomerFileRepository;
|
||||
use App\Services\Util;
|
||||
use Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
|
@ -53,14 +54,19 @@ class CustomerMailController extends Controller
|
|||
|
||||
}
|
||||
|
||||
public function store($id)
|
||||
public function store($id, $action=false)
|
||||
{
|
||||
$data = Request::all();
|
||||
$customer_mail = CustomerMail::findOrFail($id);
|
||||
|
||||
if($action === 'move-mail'){
|
||||
$data['travel_country_id'] = isset($data['travel_country_id']) && $data['travel_country_id'] ? $data['travel_country_id'] : null;
|
||||
$customer_mail->dir = $data['dir'];
|
||||
$customer_mail->travel_country_id = $data['travel_country_id'];
|
||||
$customer_mail->save();
|
||||
|
||||
}
|
||||
return back();
|
||||
/* $data = Request::all();
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('lead_detail', [$lead->id]));*/
|
||||
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
|
|
@ -201,11 +207,36 @@ class CustomerMailController extends Controller
|
|||
$status = false;
|
||||
if(Request::ajax()){
|
||||
if($data['action'] === 'toggle_important'){
|
||||
$customer_mail = CustomerMail::find($data['id']);
|
||||
$customer_mail = CustomerMail::find($data['id']);
|
||||
$customer_mail->important = ($customer_mail->important ? false : true);
|
||||
$customer_mail->save();
|
||||
$status = 'success';
|
||||
}
|
||||
if($data['action'] === 'add_attachment'){
|
||||
$arrContextOptions=array(
|
||||
"ssl"=>array(
|
||||
"verify_peer"=>false,
|
||||
"verify_peer_name"=>false,
|
||||
),
|
||||
);
|
||||
|
||||
$contents = file_get_contents($data['target'], false, stream_context_create($arrContextOptions));
|
||||
|
||||
|
||||
$mine = Util::getMimeFromHeader($http_response_header);
|
||||
$extension = Util::getExtensionFromMime($mine);
|
||||
$fileRepo = new CustomerFileRepository(new CustomerFile());
|
||||
$fileRepo->_set('disk', 'customer');
|
||||
$fileRepo->_set('dir', '/attachment/'.date('Y/m').'/');
|
||||
$fileRepo->_set('customer_id', NULL);
|
||||
$fileRepo->_set('customer_mail_id', NULL);
|
||||
$fileRepo->_set('identifier', 'tmp');
|
||||
$fileRepo->_set('originalName', $data['name']);
|
||||
$fileRepo->_set('mine', $mine);
|
||||
$fileRepo->_set('extension', $extension);
|
||||
|
||||
return $fileRepo->storeFile($contents);
|
||||
}
|
||||
}
|
||||
return response()->json(['response' => $data, 'html'=>$ret, 'status'=>$status]);
|
||||
}
|
||||
|
|
|
|||
91
app/Http/Controllers/FileController.php
Executable file
91
app/Http/Controllers/FileController.php
Executable file
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
use Response;
|
||||
use Storage;
|
||||
|
||||
class FileController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public function show($id = null, $disk = null, $do='file')
|
||||
{
|
||||
$path = "";
|
||||
$filename = "";
|
||||
if ($disk === 'customer'){
|
||||
$file = \App\Models\CustomerFile::findOrFail($id);
|
||||
$filename = $file->original_name;
|
||||
$path = $file->getPath();
|
||||
}
|
||||
|
||||
if ($disk === 'booking'){
|
||||
$file = \App\Models\BookingFile::findOrFail($id);
|
||||
$filename = $file->original_name;
|
||||
$path = $file->getPath();
|
||||
}
|
||||
|
||||
if ($disk === 'cms_file'){
|
||||
$file = \App\Models\CMSContent::findOrFail($id);
|
||||
$filename = $file->name;
|
||||
$path = $file->getPath();
|
||||
}
|
||||
|
||||
if (file_exists($path)) {
|
||||
if($do === "download"){
|
||||
return Response::download($path, $filename);
|
||||
}
|
||||
return Response::file($path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function showExpert($type = null, $class = null, $year = null, $file = null, $do = null) {
|
||||
|
||||
/*if ($type == 'xls') {
|
||||
$path = storage_path("app/export/");
|
||||
$filename = $file . '.xls';
|
||||
}*/
|
||||
$path = "";
|
||||
$filename = "";
|
||||
$headers = [];
|
||||
|
||||
if ($class === 'invoices' || $class === 'infos'){
|
||||
$headers = [
|
||||
'Content-Type: application/pdf',
|
||||
'Pragma: no-cache',
|
||||
'Cache-Control: no-store,no-cache, must-revalidate, post-check=0, pre-check=0'
|
||||
];
|
||||
$dir = $year."/";
|
||||
$filename = $file;
|
||||
if ($type === 'fewo') {
|
||||
if(Storage::disk('fewo_invoices')->exists( $dir.$filename )){
|
||||
$path = Storage::disk('fewo_invoices')->path($dir.$filename);
|
||||
}
|
||||
}
|
||||
if ($type === 'fewo') {
|
||||
if(Storage::disk('fewo_infos')->exists( $dir.$filename )){
|
||||
$path = Storage::disk('fewo_infos')->path($dir.$filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists($path)) {
|
||||
if($do === "download"){
|
||||
return Response::download($path, $filename, $headers);
|
||||
}
|
||||
if($do === "file"){
|
||||
return Response::file($path, $headers);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ use App\Models\CustomerMail;
|
|||
use App\Models\Status;
|
||||
use App\Models\Sym\TravelCountry;
|
||||
use App\Models\TravelAgenda;
|
||||
use App\Models\TravelCompany;
|
||||
use App\Repositories\CustomerMailRepository;
|
||||
use Carbon\Carbon;
|
||||
use Request;
|
||||
|
|
@ -26,9 +27,8 @@ class RequestController extends Controller
|
|||
{
|
||||
|
||||
$travel_countries = Booking::join('travel_country', 'travel_country_id', '=', 'travel_country.id')->get()->pluck('name', 'travel_country_id')->unique()->toArray();
|
||||
|
||||
$filter_lead_status = Status::get()->pluck('name', 'id')->toArray();
|
||||
|
||||
$filter_travel_company = TravelCompany::get()->pluck('name', 'id')->toArray();
|
||||
$filter_paying_out = Booking::$paying_out_types;
|
||||
$filter_paying_out_status = Booking::$paying_out_status_types;
|
||||
$filter_refund = Booking::$refund_types;
|
||||
|
|
@ -43,6 +43,7 @@ class RequestController extends Controller
|
|||
$data = [
|
||||
'step' => $step,
|
||||
'travel_countries' => $travel_countries,
|
||||
'filter_travel_company' => $filter_travel_company,
|
||||
'filter_lead_status' => $filter_lead_status,
|
||||
'filter_paying_out' => $filter_paying_out,
|
||||
'filter_paying_out_status' => $filter_paying_out_status,
|
||||
|
|
@ -96,7 +97,9 @@ class RequestController extends Controller
|
|||
if(Request::get('travel_option_agenda_id') != ""){
|
||||
$query->where('travelagenda_id', '=', Request::get('travel_option_agenda_id'));
|
||||
}
|
||||
|
||||
if(Request::get('travel_option_company_id') != ""){
|
||||
$query->where('travel_company_id', '=', Request::get('travel_option_company_id'));
|
||||
}
|
||||
if(Request::get('travel_option_lead_status_id') != ""){
|
||||
$query->whereHas('lead', function ($q) {
|
||||
$q->where('status_id', '=', Request::get('travel_option_lead_status_id'));
|
||||
|
|
@ -276,6 +279,9 @@ class RequestController extends Controller
|
|||
->addColumn('travelagenda_id', function (Booking $booking) {
|
||||
return '<span data-order="'.($booking->travelagenda_id ? $booking->travelagenda_id : 0).'">'.($booking->travelagenda_id ? $booking->travel_agenda->name : "-").'</span>';
|
||||
})
|
||||
->addColumn('travel_company_id', function (Booking $booking) {
|
||||
return '<span data-order="'.($booking->travel_company_id ? $booking->travel_company_id : 0).'">'.($booking->travel_company ? $booking->travel_company->name : "-").'</span>';
|
||||
})
|
||||
->addColumn('start_date', function (Booking $booking) {
|
||||
return $booking->getStartDateFormat();
|
||||
})
|
||||
|
|
@ -300,6 +306,13 @@ class RequestController extends Controller
|
|||
if($booking->lead->status_id == 14 && !$booking->lead->is_rebook){
|
||||
$icon = '<i class="fa fa-times-circle"></i> ';
|
||||
}
|
||||
if($booking->lead->status_id == 15){
|
||||
$icon = '<i class="fa fa-balance-scale"></i> ';
|
||||
if($booking->lawyer_date){
|
||||
return '<span data-order="'.$booking->lead->status_id.'"><span class="badge badge-dark" style="background-color: '.$color.'">'.$icon.$booking->lawyer_date->format('d.m.Y').'</span></span>';
|
||||
}
|
||||
|
||||
}
|
||||
return '<span data-order="'.$booking->lead->status_id.'"><span class="badge badge-dark" style="background-color: '.$color.'">'.$icon.$booking->lead->status->name.'</span></span>';
|
||||
}
|
||||
return '<span data-order="0">-</span>';
|
||||
|
|
@ -367,6 +380,7 @@ class RequestController extends Controller
|
|||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('travel_country_id', 'travel_country_id $1')
|
||||
->orderColumn('travelagenda_id', 'travelagenda_id $1')
|
||||
->orderColumn('travel_company_id', 'travel_company_id $1')
|
||||
->orderColumn('sf_guard_user_id', 'sf_guard_user_id $1')
|
||||
->orderColumn('start_date', 'start_date $1')
|
||||
->orderColumn('end_date', 'end_date $1')
|
||||
|
|
@ -377,7 +391,7 @@ class RequestController extends Controller
|
|||
->orderColumn('hold', 'hold $1')
|
||||
->orderColumn('xx_tkt', 'xx_tkt_date $1')
|
||||
->orderColumn('travel_documents', 'travel_documents $1')
|
||||
->rawColumns(['action_lead_edit', 'lead_id', 'participant_firstname', 'participant_name', 'action_booking_edit', 'travel_country_id', 'travelagenda_id', 'sf_guard_user_id', 'lead.status_id', 'last_customer_email', 'id', 'travel_documents', 'paying_out', 'paying_out_status', 'airline_id', 'refund', 'hold', 'xx_tkt'])
|
||||
->rawColumns(['action_lead_edit', 'lead_id', 'participant_firstname', 'participant_name', 'action_booking_edit', 'travel_country_id', 'travelagenda_id', 'travel_company_id', 'sf_guard_user_id', 'lead.status_id', 'last_customer_email', 'id', 'travel_documents', 'paying_out', 'paying_out_status', 'airline_id', 'refund', 'hold', 'xx_tkt'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,16 +33,12 @@ class MailSendInfo extends Mailable
|
|||
'content' => $this->content,
|
||||
'greetings' => __('Best regards'),
|
||||
]);
|
||||
|
||||
/* foreach ($this->files as $file) {
|
||||
foreach ($this->files as $file) {
|
||||
$message->attach($file->getPath(),[
|
||||
'as' => $file->original_name,
|
||||
'mime' => $file->mine,
|
||||
]); // attach each file
|
||||
}*/
|
||||
|
||||
foreach ($this->files as $file) {
|
||||
$message->attach((string) $file->getPath()); // attach each file
|
||||
//$message->attach((string) $file->getPath()); // attach each file
|
||||
}
|
||||
|
||||
return $message;
|
||||
|
|
|
|||
|
|
@ -154,6 +154,12 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property-read int|null $booking_stornos_count
|
||||
* @property-read int|null $booking_vouchers_count
|
||||
* @property-read int|null $travel_insurances_count
|
||||
* @property string|null $origin_start_date
|
||||
* @property \Illuminate\Support\Carbon|null $lawyer_date
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking whereLawyerDate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking whereOriginStartDate($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\BookingFile[] $booking_files
|
||||
* @property-read int|null $booking_files_count
|
||||
*/
|
||||
class Booking extends Model
|
||||
{
|
||||
|
|
@ -186,6 +192,8 @@ class Booking extends Model
|
|||
'airline_id' => 'int',
|
||||
'refund' => 'int',
|
||||
'xx_tkt' => 'int',
|
||||
'is_rail_fly' => 'bool',
|
||||
|
||||
|
||||
];
|
||||
|
||||
|
|
@ -195,7 +203,10 @@ class Booking extends Model
|
|||
'end_date',
|
||||
'participant_birthdate',
|
||||
'final_payment_date',
|
||||
'refund_date'
|
||||
'refund_date',
|
||||
'lawyer_date',
|
||||
'xx_tkt_date'
|
||||
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
|
|
@ -233,11 +244,15 @@ class Booking extends Model
|
|||
'paying_out',
|
||||
'paying_out_status',
|
||||
'airline_id',
|
||||
'hold',
|
||||
'refund',
|
||||
'refund_date',
|
||||
'lawyer_date',
|
||||
'hold',
|
||||
'xx_tkt',
|
||||
'xx_tkt_date',
|
||||
'filekey',
|
||||
'is_rail_fly',
|
||||
'notice',
|
||||
];
|
||||
|
||||
public static $paying_out_types = [
|
||||
|
|
@ -478,6 +493,11 @@ class Booking extends Model
|
|||
return $this->hasMany(TravelInsurance::class);
|
||||
}
|
||||
|
||||
public function booking_files()
|
||||
{
|
||||
return $this->hasMany(BookingFile::class);
|
||||
}
|
||||
|
||||
|
||||
public function calculate_price_total()
|
||||
{
|
||||
|
|
|
|||
103
app/Models/BookingFile.php
Normal file
103
app/Models/BookingFile.php
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class BookingFile
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $booking_id
|
||||
* @property string $identifier
|
||||
* @property string $filename
|
||||
* @property string $dir
|
||||
* @property string $original_name
|
||||
* @property string $ext
|
||||
* @property string $mine
|
||||
* @property int $size
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property Booking $booking
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingFile newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingFile newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingFile query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingFile whereBookingId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingFile whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingFile whereDir($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingFile whereExt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingFile whereFilename($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingFile whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingFile whereIdentifier($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingFile whereMine($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingFile whereOriginalName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingFile whereSize($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingFile whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class BookingFile extends Model
|
||||
{
|
||||
protected $table = 'booking_files';
|
||||
|
||||
protected $casts = [
|
||||
'booking_id' => 'int',
|
||||
'size' => 'int'
|
||||
];
|
||||
|
||||
public static $icon_ext = [
|
||||
'default' => 'fa fa-file',
|
||||
'pdf'=> 'fa fa-file-pdf',
|
||||
'jpg'=> 'fa fa-file-image',
|
||||
'png'=> 'fa fa-file-image',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'booking_id',
|
||||
'identifier',
|
||||
'filename',
|
||||
'dir',
|
||||
'original_name',
|
||||
'ext',
|
||||
'mine',
|
||||
'size'
|
||||
];
|
||||
|
||||
public function booking()
|
||||
{
|
||||
return $this->belongsTo(Booking::class);
|
||||
}
|
||||
|
||||
public function getIconExt(){
|
||||
return isset(self::$icon_ext[$this->ext]) ? self::$icon_ext[$this->ext] : self::$icon_ext['default'];
|
||||
}
|
||||
|
||||
public function getURL($do=false){
|
||||
return route('storage_file', [$this->id, 'booking', $do]);
|
||||
}
|
||||
|
||||
public function getPath(){
|
||||
return \Storage::disk('booking')->path($this->dir.$this->filename);
|
||||
|
||||
}
|
||||
|
||||
public function formatBytes($precision = 2)
|
||||
{
|
||||
$size = $this->size;
|
||||
|
||||
if ($size > 0) {
|
||||
$size = (int) $size;
|
||||
$base = log($size) / log(1024);
|
||||
$suffixes = array(' bytes', ' KB', ' MB', ' GB', ' TB');
|
||||
|
||||
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
|
||||
} else {
|
||||
return $size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -42,10 +42,19 @@ class CMSContent extends Model
|
|||
protected static $fields = [
|
||||
'text' => 'Text (190 Zeichen)',
|
||||
'full_text' => 'Full Text (50K Zeichen)',
|
||||
'file' => 'Datei (PDF/JPG/PNG)',
|
||||
'integer' => 'Zahl (10 Stellen)',
|
||||
'decimal' => 'Kommazahl (10,2 Stellen)',
|
||||
];
|
||||
|
||||
public static $icon_ext = [
|
||||
'default' => 'fa fa-file',
|
||||
'pdf'=> 'fa fa-file-pdf',
|
||||
'jpg'=> 'fa fa-file-image',
|
||||
'png'=> 'fa fa-file-image',
|
||||
|
||||
];
|
||||
|
||||
protected $connection = 'mysql_stern';
|
||||
protected $table = 'c_m_s_contents';
|
||||
|
||||
|
|
@ -78,13 +87,88 @@ class CMSContent extends Model
|
|||
|
||||
public function getPreviewContent(){
|
||||
|
||||
$content = $this->{$this->field};
|
||||
if(strlen($content) > 40){
|
||||
return substr($content, 0, 40)." ...";
|
||||
if($this->isFile()){
|
||||
$content = '<i class="'.$this->getIconExt().'"></i> <a href="'.$this->getURL().'" target="_blank">Vorschau | '.$this->formatBytes().'</a>';
|
||||
}else{
|
||||
$content = $this->{$this->field};
|
||||
if(strlen($content) > 40){
|
||||
return substr($content, 0, 40)." ...";
|
||||
}
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function getContent(){
|
||||
switch ($this->field){
|
||||
case 'text':
|
||||
return $this->text;
|
||||
break;
|
||||
case 'full_text':
|
||||
return $this->full_text;
|
||||
break;
|
||||
case 'file':
|
||||
return \GuzzleHttp\json_decode($this->full_text);
|
||||
break;
|
||||
case 'integer':
|
||||
return $this->integer;
|
||||
|
||||
break;
|
||||
case 'decimal':
|
||||
return $this->decimal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//FILE ------------------------
|
||||
public function isFile(){
|
||||
return $this->field === 'file' ? true : false;
|
||||
}
|
||||
/*'identifier', 'filename', 'dir', 'original_name', 'ext', 'mine', 'size'*/
|
||||
public function getFileContent($key= false){
|
||||
if($key && $this->isFile()){
|
||||
$file = \GuzzleHttp\json_decode($this->full_text);
|
||||
return isset($file->{$key}) ? $file->{$key} : false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getIconExt(){
|
||||
$ext = $this->getFileContent('ext');
|
||||
return isset(self::$icon_ext[$ext]) ? self::$icon_ext[$ext] : self::$icon_ext['default'];
|
||||
}
|
||||
|
||||
public function getURL($do = false){
|
||||
return route('storage_file', [$this->id, 'cms_file', $do]);
|
||||
}
|
||||
|
||||
public function getPath(){
|
||||
$dir = $this->getFileContent('dir');
|
||||
$filename = $this->getFileContent('filename');
|
||||
return \Storage::disk('public')->path($dir.$filename);
|
||||
}
|
||||
|
||||
public function formatBytes($precision = 2)
|
||||
{
|
||||
$size = $this->getFileContent('size');
|
||||
if ($size > 0) {
|
||||
$size = (int) $size;
|
||||
$base = log($size) / log(1024);
|
||||
$suffixes = array(' bytes', ' KB', ' MB', ' GB', ' TB');
|
||||
|
||||
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
|
||||
}
|
||||
return $size;
|
||||
|
||||
}
|
||||
|
||||
public function deleteFile(){
|
||||
$dir = $this->getFileContent('dir');
|
||||
$filename = $this->getFileContent('filename');
|
||||
return \Storage::disk('public')->delete($dir.$filename);
|
||||
|
||||
}
|
||||
//end FILE ------------------------
|
||||
|
||||
public function _format_number($value){
|
||||
return preg_replace("/[^0-9,]/", "", $value);
|
||||
|
|
@ -124,6 +208,9 @@ class CMSContent extends Model
|
|||
case 'full_text':
|
||||
return $CMSContent->full_text;
|
||||
break;
|
||||
case 'file':
|
||||
return \GuzzleHttp\json_decode($CMSContent->full_text);
|
||||
break;
|
||||
case 'integer':
|
||||
return $CMSContent->integer;
|
||||
|
||||
|
|
@ -131,10 +218,12 @@ class CMSContent extends Model
|
|||
case 'decimal':
|
||||
return $CMSContent->decimal;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getModelBySlug($slug){
|
||||
return CMSContent::whereSlug(trim($slug))->first();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,6 @@ class CustomerFile extends Model
|
|||
'pdf'=> 'fa fa-file-pdf',
|
||||
'jpg'=> 'fa fa-file-image',
|
||||
'png'=> 'fa fa-file-image',
|
||||
|
||||
];
|
||||
protected $fillable = [
|
||||
'customer_id',
|
||||
|
|
@ -96,12 +95,12 @@ class CustomerFile extends Model
|
|||
return isset(self::$icon_ext[$this->ext]) ? self::$icon_ext[$this->ext] : self::$icon_ext['default'];
|
||||
}
|
||||
|
||||
public function getURL(){
|
||||
return route('storage_file', [$this->id, 'customer']);
|
||||
public function getURL($do=false){
|
||||
return route('storage_file', [$this->id, 'customer', $do]);
|
||||
}
|
||||
|
||||
public function getPath(){
|
||||
return \Storage::disk('customer')->path($this->dir."/".$this->filename);
|
||||
return \Storage::disk('customer')->path($this->dir.$this->filename);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompany whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompany wherePercentage($value)
|
||||
* @mixin \Eloquent
|
||||
* @property int|null $active
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompany whereActive($value)
|
||||
*/
|
||||
class TravelCompany extends Model
|
||||
{
|
||||
|
|
|
|||
52
app/Repositories/BookingFileRepository.php
Normal file
52
app/Repositories/BookingFileRepository.php
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<?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);
|
||||
}
|
||||
|
||||
}
|
||||
53
app/Repositories/CMSFileRepository.php
Normal file
53
app/Repositories/CMSFileRepository.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\CMSContent;
|
||||
use Response;
|
||||
|
||||
class CMSFileRepository extends FileRepository {
|
||||
|
||||
protected $identifier;
|
||||
|
||||
|
||||
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",
|
||||
"full_text" => \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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -3,145 +3,53 @@
|
|||
namespace App\Repositories;
|
||||
|
||||
use App\Models\CustomerFile;
|
||||
use Request;
|
||||
use Response;
|
||||
use Storage;
|
||||
use Util;
|
||||
use Validator;
|
||||
|
||||
class CustomerFileRepository extends FileRepository {
|
||||
|
||||
|
||||
class CustomerFileRepository extends BaseRepository {
|
||||
|
||||
|
||||
protected $rules;
|
||||
protected $messages;
|
||||
|
||||
protected $disk;
|
||||
protected $dir;
|
||||
protected $customer_file;
|
||||
protected $customer_id;
|
||||
protected $customer_mail_id;
|
||||
protected $identifier;
|
||||
|
||||
|
||||
public function __construct(CustomerFile $model){
|
||||
|
||||
parent::__construct();
|
||||
$this->model = $model;
|
||||
|
||||
$this->rules = [
|
||||
'file' => 'required|mimes:pdf,jpeg,png|max:32768'
|
||||
];
|
||||
$this->messages = [
|
||||
'file.mimes' => 'Datei ist kein PDF/JPG/PNG Format',
|
||||
'file.required' => 'PDF/JPG/PNG-Datei wird benötigt'
|
||||
];
|
||||
}
|
||||
|
||||
public function _set($name, $value){
|
||||
$this->{$name} = $value;
|
||||
}
|
||||
|
||||
/* public function load($id){
|
||||
$this->model = $id;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public function uploadFile( $form_data )
|
||||
{
|
||||
|
||||
$validator = Validator::make($form_data, $this->rules, $this->messages);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return Response::json([
|
||||
'error' => true,
|
||||
'message' => $validator->messages()->first(),
|
||||
'code' => 400
|
||||
], 400);
|
||||
}
|
||||
$file = $form_data['file'];
|
||||
|
||||
$originalName = $file->getClientOriginalName();
|
||||
$extension = $file->getClientOriginalExtension();
|
||||
$mine = $file->getClientMimeType();
|
||||
$size = $file->getClientSize();
|
||||
|
||||
|
||||
$originalNameWithoutExt = substr($originalName, 0, strlen($originalName) - strlen($extension) - 1);
|
||||
$filename = Util::sanitize($originalNameWithoutExt, true, false, true);
|
||||
$allowed_filename = uniqid() . '_' . $filename.".".$extension;
|
||||
|
||||
//$dir = $this->model->getInvoiceStorageAttDir();
|
||||
|
||||
if(!Storage::disk($this->disk)->exists( $this->dir )){
|
||||
Storage::disk($this->disk)->makeDirectory($this->dir); //creates directory
|
||||
}
|
||||
Storage::disk($this->disk)->put($this->dir.$allowed_filename, file_get_contents($file->getRealPath()));
|
||||
|
||||
$customer_file = CustomerFile::create([
|
||||
public function save(){
|
||||
$this->customer_file = CustomerFile::create([
|
||||
'customer_id' => $this->customer_id,
|
||||
'customer_mail_id' => $this->customer_mail_id,
|
||||
'identifier' => $this->identifier,
|
||||
'filename' => $allowed_filename,
|
||||
'filename' => $this->allowed_filename,
|
||||
'dir' => $this->dir,
|
||||
'original_name' => $originalName,
|
||||
'ext' => $extension,
|
||||
'mine' => $mine,
|
||||
'size' => $size
|
||||
'original_name' => $this->originalName,
|
||||
'ext' => $this->extension,
|
||||
'mine' => $this->mine,
|
||||
'size' => $this->size
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function response(){
|
||||
return Response::json([
|
||||
'error' => false,
|
||||
'filename' => $allowed_filename,
|
||||
'file_id' =>$customer_file->id,
|
||||
'file_data' => $extension,
|
||||
'file_icon' => $customer_file->getIconExt(),
|
||||
'file_format_bytes' => $customer_file->formatBytes(),
|
||||
'file_url' => $customer_file->getURL(),
|
||||
'original_name' => $this->originalName,
|
||||
'filename' => $this->allowed_filename,
|
||||
'file_id' =>$this->customer_file->id,
|
||||
'file_data' => $this->extension,
|
||||
'file_icon' => $this->customer_file->getIconExt(),
|
||||
'file_format_bytes' => $this->customer_file->formatBytes(),
|
||||
'file_url' => $this->customer_file->getURL(),
|
||||
'redirect' => '',
|
||||
'code' => 200
|
||||
], 200);
|
||||
}
|
||||
|
||||
/* public function createFile(Request $request)
|
||||
{
|
||||
$locale = \App::getLocale();
|
||||
$data = [
|
||||
'step' => 2,
|
||||
'locale' => $locale,
|
||||
];
|
||||
$rules = array(
|
||||
'network_name' => 'required|max:255',
|
||||
'input_file_now' => 'required|mimes:png,pdf,jpg,jpeg|max:30000'
|
||||
);
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
// get the error messages from the validator
|
||||
$messages = $validator->messages();
|
||||
// redirect our user back to the form with the errors from the validator
|
||||
return view('user.register_complete', $data)->withErrors($validator);
|
||||
|
||||
} else {
|
||||
$user = \Auth::user();
|
||||
if(!$user->account->network_name){
|
||||
$file = request()->file('input_file_now');
|
||||
//$ext = $file->guessClientExtension();
|
||||
//$file->storeAs('user/' . $user->id .'/verification');
|
||||
$data = $file->store('user/' . $user->id .'/verification');
|
||||
$account = $user->account;
|
||||
$account->network_name = Input::get('network_name');
|
||||
$account->network_verification = basename($data);
|
||||
$account->save();
|
||||
|
||||
$user->role_id = 2; //set as User by default!
|
||||
$user->save();
|
||||
|
||||
|
||||
}
|
||||
|
||||
return redirect('complete_register');
|
||||
//return view('user.register_complete', $data);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ namespace App\Repositories;
|
|||
use App\Mail\MailSendInfo;
|
||||
use App\Models\Airline;
|
||||
use App\Models\Booking;
|
||||
use App\Models\CMSContent;
|
||||
use App\Models\CustomerFile;
|
||||
use App\Models\CustomerMail;
|
||||
use App\Services\Util;
|
||||
|
|
@ -168,12 +169,12 @@ class CustomerMailRepository extends BaseRepository {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function prepareContent($booking, $content){
|
||||
|
||||
$first_name = $booking->customer->firstname;
|
||||
$last_name = $booking->customer->name;
|
||||
$title = $booking->customer->title;
|
||||
|
||||
$country = $booking->travel_country_id ? $booking->travel_country->name : "-";
|
||||
$program = $booking->travelagenda_id ? $booking->travel_agenda->name : "-";
|
||||
$salutation = $booking->customer->salutation->name;
|
||||
|
|
@ -183,8 +184,8 @@ class CustomerMailRepository extends BaseRepository {
|
|||
$airline = $booking->airline ? $booking->airline->name_full : '-';
|
||||
|
||||
$dear = $booking->customer->salutation_id == 1 ? 'geehrter' : 'geehrte';
|
||||
$search = ['#geehrte/r#', '#Anrede#', '#Vorname#', '#Nachname#', '#Reiseland#', '#Programm#', '#Anreisedatum#', '#Abreisedatum#', '#Buchungsdatum#', '#Airline#'];
|
||||
$replace = [$dear, $salutation, $first_name, $last_name, $country, $program, $start_date, $end_date, $booking_date, $airline];
|
||||
$search = ['#geehrte/r#', '#Anrede#', '#Titel#', '#Vorname#', '#Nachname#', '#Reiseland#', '#Programm#', '#Anreisedatum#', '#Abreisedatum#', '#Buchungsdatum#', '#Airline#'];
|
||||
$replace = [$dear, $salutation, $title, $first_name, $last_name, $country, $program, $start_date, $end_date, $booking_date, $airline];
|
||||
$content = str_replace($search, $replace, $content);
|
||||
|
||||
return $content;
|
||||
|
|
@ -287,19 +288,22 @@ class CustomerMailRepository extends BaseRepository {
|
|||
if ($data['action'] === "new-customer-mail") {
|
||||
$value->id = "";
|
||||
$value->draft = false;
|
||||
$lead_id = "-";
|
||||
//singel
|
||||
if (isset($data['booking_id']) && $booking = Booking::find($data['booking_id'])) {
|
||||
$value->id = $data['booking_id'];
|
||||
$value->booking = $booking;
|
||||
$value->show = 'single';
|
||||
$value->draft = true;
|
||||
$lead_id = " - (".$value->booking->lead_id.")";
|
||||
|
||||
}else{
|
||||
//multi
|
||||
$value->show = 'multi';
|
||||
}
|
||||
$value->customers = $data['customers'];
|
||||
$value->subject = "";
|
||||
$value->message = "<p>Sehr #geehrte/r# #Anrede# #Vorname# #Nachname#,</p><p>Text ...</p>";
|
||||
$value->subject = $lead_id ;
|
||||
$value->message = CMSContent::getContentBySlug('mailvorlage');
|
||||
$value->s_placeholder = "Betreff der E-Mail";
|
||||
$value->m_placeholder = "Nachricht der E-Mail";
|
||||
if(isset($data['customer_mail_id']) && $customer_mail = CustomerMail::find($data['customer_mail_id'])){
|
||||
|
|
|
|||
108
app/Repositories/FileRepository.php
Normal file
108
app/Repositories/FileRepository.php
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use Response;
|
||||
use Storage;
|
||||
use Util;
|
||||
use Validator;
|
||||
|
||||
class FileRepository extends BaseRepository {
|
||||
|
||||
|
||||
protected $rules;
|
||||
protected $messages;
|
||||
|
||||
protected $disk;
|
||||
protected $dir;
|
||||
|
||||
protected $filename;
|
||||
protected $allowed_filename;
|
||||
protected $originalName;
|
||||
protected $extension;
|
||||
protected $mine;
|
||||
protected $size;
|
||||
|
||||
|
||||
public function __construct(){
|
||||
|
||||
$this->rules = [
|
||||
'file' => 'required|mimes:pdf,jpeg,png|max:32768'
|
||||
];
|
||||
$this->messages = [
|
||||
'file.mimes' => 'Datei ist kein PDF/JPG/PNG Format',
|
||||
'file.required' => 'PDF/JPG/PNG-Datei wird benötigt'
|
||||
];
|
||||
}
|
||||
|
||||
public function _set($name, $value){
|
||||
$this->{$name} = $value;
|
||||
}
|
||||
|
||||
public function uploadFile( $form_data )
|
||||
{
|
||||
$validator = Validator::make($form_data, $this->rules, $this->messages);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return Response::json([
|
||||
'error' => true,
|
||||
'message' => $validator->messages()->first(),
|
||||
'code' => 400
|
||||
], 400);
|
||||
}
|
||||
$file = $form_data['file'];
|
||||
|
||||
$this->originalName = $file->getClientOriginalName();
|
||||
$this->extension = strtolower($file->getClientOriginalExtension());
|
||||
$this->mine = $file->getClientMimeType();
|
||||
$this->size = $file->getClientSize();
|
||||
|
||||
|
||||
$this->makeFilename();
|
||||
//$dir = $this->model->getInvoiceStorageAttDir();
|
||||
|
||||
$this->store(file_get_contents($file->getRealPath()));
|
||||
$this->save();
|
||||
return $this->response();
|
||||
|
||||
}
|
||||
|
||||
public function storeFile( $content )
|
||||
{
|
||||
$this->makeFilename();
|
||||
$this->store($content);
|
||||
$this->size = Storage::disk($this->disk)->size($this->dir.$this->allowed_filename);
|
||||
$this->save();
|
||||
return $this->response();
|
||||
}
|
||||
|
||||
public function store($content){
|
||||
if(!Storage::disk($this->disk)->exists( $this->dir )){
|
||||
Storage::disk($this->disk)->makeDirectory($this->dir); //creates directory
|
||||
}
|
||||
Storage::disk($this->disk)->put($this->dir.$this->allowed_filename, $content);
|
||||
}
|
||||
|
||||
public function save(){
|
||||
|
||||
}
|
||||
|
||||
public function response(){
|
||||
return Response::json([
|
||||
'error' => false,
|
||||
'filename' => $this->allowed_filename,
|
||||
'originalName' => $this->originalName,
|
||||
'file_data' => $this->extension,
|
||||
'mine' => $this->mine,
|
||||
'size' => $this->size,
|
||||
'redirect' => '',
|
||||
'code' => 200
|
||||
], 200);
|
||||
}
|
||||
|
||||
private function makeFilename(){
|
||||
$originalNameWithoutExt = substr($this->originalName, 0, strlen($this->originalName) - strlen($this->extension) - 1);
|
||||
$this->filename = Util::sanitize($originalNameWithoutExt, true, false, true);
|
||||
$this->allowed_filename = uniqid("", true) . '_' . $this->filename.".".$this->extension;
|
||||
}
|
||||
}
|
||||
|
|
@ -93,7 +93,7 @@ class CreateCouponPDF {
|
|||
$pdf->SetFont('Helvetica', '', 10);
|
||||
|
||||
$customerName = ($this->coupon->customer && $this->coupon->customer->salutation ? $this->coupon->customer->salutation->name . ' ' : '' )
|
||||
. ($this->coupon->customer->title ? $$this->coupon->customer->title . ' ' : '' )
|
||||
. ($this->coupon->customer->title ? $this->coupon->customer->title . ' ' : '' )
|
||||
. $this->coupon->customer->fullName();
|
||||
$customerStreet = $this->coupon->customer ? $this->coupon->customer->street : '';
|
||||
$customerRegion = $this->coupon->customer->zip ? $this->coupon->customer->zip." " : '';
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ class Util
|
|||
$clean = ($anal) ? preg_replace("/[^a-zA-Z0-9]/", "", $clean) : $clean ;
|
||||
|
||||
if($substr){
|
||||
$clean = (strlen($clean) > 33) ? substr($clean,-33) : $clean;
|
||||
$clean = (strlen($clean) > 33) ? substr($clean,0,33) : $clean;
|
||||
|
||||
}
|
||||
return ($force_lowercase) ?
|
||||
|
|
@ -172,4 +172,31 @@ class Util
|
|||
$charset = mb_detect_encoding($value, "UTF-8, ISO-8859-1, ISO-8859-15", true);
|
||||
return mb_convert_encoding($value, "Windows-1252", $charset);
|
||||
}
|
||||
|
||||
|
||||
public static function getMimeFromHeader($http_response_header){
|
||||
$pattern = "/^content-type\s*:\s*(.*)$/i";
|
||||
if (($header = array_values(preg_grep($pattern, $http_response_header))) &&
|
||||
(preg_match($pattern, $header[0], $match) !== false))
|
||||
{
|
||||
return $match[1];
|
||||
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static function getExtensionFromMime($mine){
|
||||
$mime_types = [
|
||||
'application/pdf' => 'pdf',
|
||||
'image/png' => 'png',
|
||||
'image/jpg' => 'jpg',
|
||||
'image/jpeg' => 'jpg',
|
||||
'text/html; charset=UTF-8' => 'html',
|
||||
'text/html' => 'html',
|
||||
|
||||
];
|
||||
return isset($mime_types[$mine]) ? $mime_types[$mine] : "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue