Upload Files Booking, Mails, Attachments,
This commit is contained in:
parent
5daea268f7
commit
68b9d1ff88
92 changed files with 2837 additions and 1778 deletions
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue