Fewo Mails / Booking Country Services
This commit is contained in:
parent
b9c26d06d0
commit
48a6eb2282
154 changed files with 7761 additions and 1643 deletions
|
|
@ -47,4 +47,12 @@ class Airline extends Model
|
|||
|
||||
protected $casts = ['contact_emails' => 'array'];
|
||||
|
||||
public static function getAsNameIdArray($empty = true){
|
||||
$ret = Airline::get()->pluck('name', 'id')->toArray();
|
||||
if($empty){
|
||||
$first = [null => "-"];
|
||||
return $first + $ret;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -287,11 +287,12 @@ class Booking extends Model
|
|||
2 => 'erledigt',
|
||||
];
|
||||
|
||||
public static $hold_types = [
|
||||
0 => '-',
|
||||
1 => 'eingetragen',
|
||||
];
|
||||
|
||||
public static $customer_mail_dirs = [
|
||||
0 => ['name' => 'Reisender', 'icon'=>'ion-ios-filing'],
|
||||
1 => ['name' => 'Agentur', 'icon'=>'ion-ios-folder-open'],
|
||||
2 => ['name' => 'Flug', 'icon'=>'ion-ios-airplane'],
|
||||
3 => ['name' => 'Versicherung', 'icon'=>'ion-ios-help-buoy'],
|
||||
11 => ['name' => 'Entwürfe', 'icon'=>'ion-md-create'],
|
||||
12 => ['name' => 'Papierkorb', 'icon'=>'ion-md-trash'],
|
||||
];
|
||||
|
|
@ -473,6 +474,23 @@ class Booking extends Model
|
|||
return $this->hasMany(BookingFile::class);
|
||||
}
|
||||
|
||||
public function booking_country_services()
|
||||
{
|
||||
return $this->hasMany(BookingCountryService::class, 'booking_id');
|
||||
}
|
||||
|
||||
public function booking_country_services_checked()
|
||||
{
|
||||
return $this->hasMany(BookingCountryService::class, 'booking_id')->where('status', '=', 0);
|
||||
}
|
||||
|
||||
public function hasBookingCountryServicesUnchecked(){
|
||||
if(!$this->booking_country_services->count() || $this->booking_country_services_checked->count() ||
|
||||
($this->booking_country_services->count() !== TravelCountryService::where('crm_travel_country_id', '=', $this->travel_country_id)->count())){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function calculate_price_total()
|
||||
{
|
||||
|
|
@ -740,13 +758,13 @@ class Booking extends Model
|
|||
return isset($this->xx_tkt_colors[$this->xx_tkt]) ? $this->xx_tkt_colors[$this->xx_tkt] : '-';
|
||||
}
|
||||
|
||||
public function countCustomerMailsBy($dir, $country=false){
|
||||
public function countCustomerMailsBy($dir, $subdir=false){
|
||||
|
||||
if($dir === 11){
|
||||
return $this->customer_mails->where('draft', true)->count();
|
||||
return $this->customer_mails->where('draft', true)->where('dir', '!=', 12)->count();
|
||||
}
|
||||
if($country){
|
||||
return $this->customer_mails->where('dir', $dir)->where('travel_country_id', $country)->count();
|
||||
if($subdir){
|
||||
return $this->customer_mails->where('dir', $dir)->where('subdir', $subdir)->count();
|
||||
}
|
||||
return $this->customer_mails->where('dir', $dir)->count();
|
||||
}
|
||||
|
|
|
|||
75
app/Models/BookingCountryService.php
Normal file
75
app/Models/BookingCountryService.php
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class BookingCountryService
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $travel_country_service_id
|
||||
* @property int $booking_id
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property Booking $booking
|
||||
* @property TravelCountryService $travel_country_service
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCountryService newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCountryService newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCountryService query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCountryService whereBookingId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCountryService whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCountryService whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCountryService whereTravelCountryServiceId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCountryService whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class BookingCountryService extends Model
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
|
||||
protected $table = 'booking_country_services';
|
||||
|
||||
protected $casts = [
|
||||
'travel_country_service_id' => 'int',
|
||||
'booking_id' => 'int',
|
||||
'status' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'travel_country_service_id',
|
||||
'booking_id',
|
||||
'status'
|
||||
];
|
||||
|
||||
protected $status_type = [
|
||||
0 => 'offen',
|
||||
1 => 'erledigt',
|
||||
];
|
||||
|
||||
public function booking()
|
||||
{
|
||||
return $this->belongsTo(Booking::class);
|
||||
}
|
||||
|
||||
public function travel_country_service()
|
||||
{
|
||||
return $this->belongsTo(TravelCountryService::class);
|
||||
}
|
||||
|
||||
public static function getStatus($travel_country_service_id, $booking_id){
|
||||
$booking_country_service = BookingCountryService::where('travel_country_service_id', '=', $travel_country_service_id)
|
||||
->where('booking_id', '=', $booking_id)->first();
|
||||
|
||||
if($booking_country_service){
|
||||
return $booking_country_service->status;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -50,13 +50,6 @@ class BookingFile extends Model
|
|||
'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',
|
||||
|
|
@ -68,6 +61,13 @@ class BookingFile extends Model
|
|||
'size'
|
||||
];
|
||||
|
||||
public static $icon_ext = [
|
||||
'default' => 'fa fa-file',
|
||||
'pdf'=> 'fa fa-file-pdf',
|
||||
'jpg'=> 'fa fa-file-image',
|
||||
'png'=> 'fa fa-file-image',
|
||||
];
|
||||
|
||||
public function booking()
|
||||
{
|
||||
return $this->belongsTo(Booking::class);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,12 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSContent newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSContent newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSContent query()
|
||||
* @property string|null $identifier
|
||||
* @property array|null $object
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSContent whereIdentifier($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSContent whereObject($value)
|
||||
* @property int|null $pos
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSContent wherePos($value)
|
||||
*/
|
||||
class CMSContent extends Model
|
||||
{
|
||||
|
|
@ -59,7 +65,12 @@ class CMSContent extends Model
|
|||
protected $table = 'c_m_s_contents';
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'slug', 'field', 'text', 'full_text', 'integer', 'decimal',
|
||||
'name', 'slug', 'identifier', 'field', 'text', 'full_text', 'object', 'integer', 'decimal', 'pos',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'object' => 'array',
|
||||
'pos' => 'int'
|
||||
];
|
||||
|
||||
public function sluggable()
|
||||
|
|
@ -107,11 +118,14 @@ class CMSContent extends Model
|
|||
return $this->full_text;
|
||||
break;
|
||||
case 'file':
|
||||
return \GuzzleHttp\json_decode($this->full_text);
|
||||
// return \GuzzleHttp\json_decode($this->full_text);
|
||||
return $this->object;
|
||||
break;
|
||||
case 'array':
|
||||
return $this->object;
|
||||
break;
|
||||
case 'integer':
|
||||
return $this->integer;
|
||||
|
||||
break;
|
||||
case 'decimal':
|
||||
return $this->decimal;
|
||||
|
|
@ -122,13 +136,21 @@ class CMSContent extends Model
|
|||
|
||||
//FILE ------------------------
|
||||
public function isFile(){
|
||||
return $this->field === 'file' ? true : false;
|
||||
return $this->id > 0 && $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;
|
||||
// $file = \GuzzleHttp\json_decode($this->full_text);
|
||||
return isset($this->object[$key]) ? $this->object[$key] : false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getArrayContent($key= false){
|
||||
if($key && $this->field === 'array'){
|
||||
// $file = \GuzzleHttp\json_decode($this->full_text);
|
||||
return isset($this->object[$key]) ? $this->object[$key] : false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -209,7 +231,10 @@ class CMSContent extends Model
|
|||
return $CMSContent->full_text;
|
||||
break;
|
||||
case 'file':
|
||||
return \GuzzleHttp\json_decode($CMSContent->full_text);
|
||||
return $CMSContent->object; //\GuzzleHttp\json_decode($CMSContent->full_text);
|
||||
break;
|
||||
case 'array':
|
||||
return $CMSContent->object; //\GuzzleHttp\json_decode($CMSContent->full_text);
|
||||
break;
|
||||
case 'integer':
|
||||
return $CMSContent->integer;
|
||||
|
|
|
|||
115
app/Models/CustomerFewoFile.php
Normal file
115
app/Models/CustomerFewoFile.php
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class CustomerFewoFile
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $travel_user_id
|
||||
* @property int $customer_fewo_mail_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 CustomerFewoMail $customer_fewo_mail
|
||||
* @property TravelUser $travel_user
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereCustomerFewoMailId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereDir($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereExt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereFilename($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereIdentifier($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereMine($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereOriginalName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereSize($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereTravelUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class CustomerFewoFile extends Model
|
||||
{
|
||||
protected $connection = 'mysql_stern';
|
||||
|
||||
protected $table = 'customer_fewo_files';
|
||||
|
||||
protected $casts = [
|
||||
'travel_user_id' => 'int',
|
||||
'customer_fewo_mail_id' => 'int',
|
||||
'size' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'travel_user_id',
|
||||
'customer_fewo_mail_id',
|
||||
'identifier',
|
||||
'filename',
|
||||
'dir',
|
||||
'original_name',
|
||||
'ext',
|
||||
'mine',
|
||||
'size'
|
||||
];
|
||||
|
||||
public static $icon_ext = [
|
||||
'default' => 'fa fa-file',
|
||||
'pdf'=> 'fa fa-file-pdf',
|
||||
'jpg'=> 'fa fa-file-image',
|
||||
'png'=> 'fa fa-file-image',
|
||||
];
|
||||
|
||||
public function customer_fewo_mail()
|
||||
{
|
||||
return $this->belongsTo(CustomerFewoMail::class);
|
||||
}
|
||||
|
||||
public function travel_user()
|
||||
{
|
||||
return $this->belongsTo(TravelUser::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, 'travel_user', $do]);
|
||||
}
|
||||
|
||||
public function getPath(){
|
||||
return \Storage::disk('travel_user')->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;
|
||||
}
|
||||
}
|
||||
}
|
||||
189
app/Models/CustomerFewoMail.php
Normal file
189
app/Models/CustomerFewoMail.php
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class CustomerFewoMail
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $travel_user_booking_fewo_id
|
||||
* @property int $travel_user_id
|
||||
* @property bool $is_answer
|
||||
* @property int $reply_id
|
||||
* @property string $email
|
||||
* @property string $recipient
|
||||
* @property string $cc
|
||||
* @property string $bcc
|
||||
* @property string $subject
|
||||
* @property string $message
|
||||
* @property int $dir
|
||||
* @property int $subdir
|
||||
* @property bool $draft
|
||||
* @property bool $important
|
||||
* @property bool $send
|
||||
* @property bool $fail
|
||||
* @property string $error
|
||||
* @property Carbon $sent_at
|
||||
* @property Carbon $scheduled_at
|
||||
* @property Carbon $delivered_at
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property CustomerFewoMail $customer_fewo_mail
|
||||
* @property TravelUserBookingFewo $travel_user_booking_fewo
|
||||
* @property TravelUser $travel_user
|
||||
* @property Collection|CustomerFewoFile[] $customer_fewo_files
|
||||
* @property Collection|CustomerFewoMail[] $customer_fewo_mails
|
||||
* @package App\Models
|
||||
* @property-read int|null $customer_fewo_files_count
|
||||
* @property-read int|null $customer_fewo_mails_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereBcc($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereCc($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereDeliveredAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereDir($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereDraft($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereEmail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereError($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereFail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereImportant($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereIsAnswer($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereMessage($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereRecipient($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereReplyId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereScheduledAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereSend($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereSentAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereSubdir($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereSubject($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereTravelUserBookingFewoId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereTravelUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property-read \App\Models\TravelUserBookingFewo $booking
|
||||
* @property-read \App\Models\TravelUser $customer
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\CustomerFewoFile[] $customer_files
|
||||
* @property-read int|null $customer_files_count
|
||||
* @property-read \App\Models\CustomerFewoMail|null $customer_mail
|
||||
*/
|
||||
class CustomerFewoMail extends Model
|
||||
{
|
||||
protected $connection = 'mysql_stern';
|
||||
|
||||
protected $table = 'customer_fewo_mails';
|
||||
|
||||
protected $casts = [
|
||||
'travel_user_booking_fewo_id' => 'int',
|
||||
'travel_user_id' => 'int',
|
||||
'is_answer' => 'bool',
|
||||
'reply_id' => 'int',
|
||||
'dir' => 'int',
|
||||
'subdir' => 'int',
|
||||
'draft' => 'bool',
|
||||
'important' => 'bool',
|
||||
'send' => 'bool',
|
||||
'fail' => 'bool',
|
||||
'recipient' => 'array',
|
||||
'cc' => 'array',
|
||||
'bcc' => 'array'
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'sent_at',
|
||||
'scheduled_at',
|
||||
'delivered_at'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'travel_user_booking_fewo_id',
|
||||
'travel_user_id',
|
||||
'is_answer',
|
||||
'reply_id',
|
||||
'email',
|
||||
'recipient',
|
||||
'cc',
|
||||
'bcc',
|
||||
'subject',
|
||||
'message',
|
||||
'dir',
|
||||
'subdir',
|
||||
'draft',
|
||||
'important',
|
||||
'send',
|
||||
'fail',
|
||||
'error',
|
||||
'sent_at',
|
||||
'scheduled_at',
|
||||
'delivered_at'
|
||||
];
|
||||
|
||||
public function customer_fewo_mail()
|
||||
{
|
||||
return $this->belongsTo(CustomerFewoMail::class, 'reply_id');
|
||||
}
|
||||
|
||||
public function customer_mail()
|
||||
{
|
||||
return $this->belongsTo(CustomerFewoMail::class, 'reply_id');
|
||||
}
|
||||
|
||||
public function travel_user_booking_fewo()
|
||||
{
|
||||
return $this->belongsTo(TravelUserBookingFewo::class);
|
||||
}
|
||||
|
||||
public function booking()
|
||||
{
|
||||
return $this->belongsTo(TravelUserBookingFewo::class);
|
||||
}
|
||||
|
||||
public function travel_user()
|
||||
{
|
||||
return $this->belongsTo(TravelUser::class);
|
||||
}
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(TravelUser::class, 'travel_user_id');
|
||||
}
|
||||
|
||||
public function customer_fewo_files()
|
||||
{
|
||||
return $this->hasMany(CustomerFewoFile::class);
|
||||
}
|
||||
|
||||
public function customer_files()
|
||||
{
|
||||
return $this->hasMany(CustomerFewoFile::class, 'customer_fewo_mail_id');
|
||||
}
|
||||
|
||||
public function customer_fewo_mails()
|
||||
{
|
||||
return $this->hasMany(CustomerFewoMail::class, 'reply_id');
|
||||
}
|
||||
|
||||
public function getSentAtRaw(){
|
||||
return $this->attributes['sent_at'];
|
||||
}
|
||||
|
||||
public function getSentAtAttribute(){
|
||||
if(!$this->attributes['sent_at']){ return ""; }
|
||||
return Carbon::parse($this->attributes['sent_at'])->format(\Util::formatDateTimeDB());
|
||||
}
|
||||
|
||||
public function getCreatedAtAttribute(){
|
||||
if(!$this->attributes['created_at']){ return ""; }
|
||||
return Carbon::parse($this->attributes['created_at'])->format(\Util::formatDateTimeDB());
|
||||
}
|
||||
}
|
||||
|
|
@ -58,12 +58,6 @@ class CustomerFile extends Model
|
|||
'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 = [
|
||||
'customer_id',
|
||||
'customer_mail_id',
|
||||
|
|
@ -76,6 +70,13 @@ class CustomerFile extends Model
|
|||
'size'
|
||||
];
|
||||
|
||||
public static $icon_ext = [
|
||||
'default' => 'fa fa-file',
|
||||
'pdf'=> 'fa fa-file-pdf',
|
||||
'jpg'=> 'fa fa-file-image',
|
||||
'png'=> 'fa fa-file-image',
|
||||
];
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereTravelCountryId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property int|null $subdir
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereSubdir($value)
|
||||
*/
|
||||
class CustomerMail extends Model
|
||||
{
|
||||
|
|
@ -96,7 +98,8 @@ class CustomerMail extends Model
|
|||
'is_answer' => 'bool',
|
||||
'reply_id' => 'int',
|
||||
'dir' => 'int',
|
||||
'travel_country_id' => 'int',
|
||||
'subdir' => 'int',
|
||||
'travel_country_id' => 'int',
|
||||
'draft' => 'bool',
|
||||
'important' => 'bool',
|
||||
'send' => 'bool',
|
||||
|
|
@ -125,7 +128,8 @@ class CustomerMail extends Model
|
|||
'subject',
|
||||
'message',
|
||||
'dir',
|
||||
'travel_country_id',
|
||||
'subdir',
|
||||
'travel_country_id',
|
||||
'draft',
|
||||
'important',
|
||||
'send',
|
||||
|
|
|
|||
|
|
@ -11,29 +11,49 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
/**
|
||||
* Class EmailTemplate
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $email_template_dir_id
|
||||
* @property string $subject
|
||||
* @property string $message
|
||||
* @property bool $active
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*
|
||||
* @property EmailTemplateDir $email_template_dir
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate whereEmailTemplateDirId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate whereMessage($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate whereSubject($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string $name
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate whereName($value)
|
||||
*/
|
||||
class EmailTemplate extends Model
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
|
||||
protected $table = 'email_templates';
|
||||
protected $table = 'email_templates';
|
||||
|
||||
protected $casts = [
|
||||
'email_template_dir_id' => 'int',
|
||||
'active' => 'bool'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'email_template_dir_id',
|
||||
'name',
|
||||
'subject',
|
||||
'message',
|
||||
'active'
|
||||
];
|
||||
|
||||
public function email_template_dir()
|
||||
{
|
||||
return $this->belongsTo(EmailTemplateDir::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
58
app/Models/EmailTemplateDir.php
Normal file
58
app/Models/EmailTemplateDir.php
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class EmailTemplateDir
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $color
|
||||
* @property bool $active
|
||||
* @property int $pos
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property Collection|EmailTemplate[] $email_templates
|
||||
* @package App\Models
|
||||
* @property-read int|null $email_templates_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplateDir newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplateDir newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplateDir query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplateDir whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplateDir whereColor($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplateDir whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplateDir whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplateDir whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplateDir wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplateDir whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class EmailTemplateDir extends Model
|
||||
{
|
||||
protected $table = 'email_template_dirs';
|
||||
|
||||
protected $casts = [
|
||||
'active' => 'bool',
|
||||
'pos' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'color',
|
||||
'active',
|
||||
'pos'
|
||||
];
|
||||
|
||||
public function email_templates()
|
||||
{
|
||||
return $this->hasMany(EmailTemplate::class);
|
||||
}
|
||||
}
|
||||
106
app/Models/GeneralFile.php
Normal file
106
app/Models/GeneralFile.php
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class GeneralFile
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $travel_country_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 TravelCountry $travel_country
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereDir($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereExt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereFilename($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereIdentifier($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereMine($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereOriginalName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereSize($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereTravelCountryId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class GeneralFile extends Model
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
|
||||
protected $table = 'general_files';
|
||||
|
||||
protected $casts = [
|
||||
'travel_country_id' => 'int',
|
||||
'size' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'travel_country_id',
|
||||
'identifier',
|
||||
'filename',
|
||||
'dir',
|
||||
'original_name',
|
||||
'ext',
|
||||
'mine',
|
||||
'size'
|
||||
];
|
||||
|
||||
public static $icon_ext = [
|
||||
'default' => 'fa fa-file',
|
||||
'pdf'=> 'fa fa-file-pdf',
|
||||
'jpg'=> 'fa fa-file-image',
|
||||
'png'=> 'fa fa-file-image',
|
||||
];
|
||||
|
||||
|
||||
public function travel_country()
|
||||
{
|
||||
return $this->belongsTo(TravelCountry::class, 'travel_country_id');
|
||||
}
|
||||
|
||||
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, 'general', $do]);
|
||||
}
|
||||
|
||||
public function getPath(){
|
||||
return \Storage::disk('general')->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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
/**
|
||||
* Class Insurance
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $name_full
|
||||
|
|
@ -19,8 +19,17 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property bool $active
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Insurance newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Insurance newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Insurance query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Insurance whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Insurance whereContactEmails($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Insurance whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Insurance whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Insurance whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Insurance whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Insurance extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProvider whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProvider whereType($value)
|
||||
* @mixin \Eloquent
|
||||
* @property array|null $contact_emails
|
||||
* @property bool|null $active
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProvider whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProvider whereContactEmails($value)
|
||||
*/
|
||||
class ServiceProvider extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,6 +34,12 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent findSimilarSlugs($attribute, $config, $slug)
|
||||
* @property string|null $identifier
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereIdentifier($value)
|
||||
* @property array|null $object
|
||||
* @property int|null $pos
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereObject($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent wherePos($value)
|
||||
*/
|
||||
class CmsContent extends Model
|
||||
{
|
||||
|
|
@ -45,7 +51,12 @@ class CmsContent extends Model
|
|||
protected $table = 'cms_contents';
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'slug', 'field', 'text', 'full_text', 'integer', 'decimal',
|
||||
'name', 'slug', 'identifier', 'field', 'text', 'full_text', 'object', 'integer', 'decimal', 'pos',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'object' => 'array',
|
||||
'pos' => 'int'
|
||||
];
|
||||
|
||||
public $timestamps = false;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@
|
|||
namespace App\Models\Sym;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\GeneralFile;
|
||||
use App\Models\Lead;
|
||||
use App\Models\TravelCountryService;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
|
||||
|
|
@ -40,6 +42,13 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property-read int|null $bookings_count
|
||||
* @property array|null $contact_emails
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereContactEmails($value)
|
||||
* @property array|null $mail_dirs
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereMailDirs($value)
|
||||
* @property string|null $mail_dir_name
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereMailDirName($value)
|
||||
* @property-read \App\Models\TravelCountry|null $stern_travel_country
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\TravelCountryService[] $travel_country_services
|
||||
* @property-read int|null $travel_country_services_count
|
||||
*/
|
||||
class TravelCountry extends Model
|
||||
{
|
||||
|
|
@ -53,6 +62,8 @@ class TravelCountry extends Model
|
|||
'is_customer_country',
|
||||
'active_backend',
|
||||
'contact_lands',
|
||||
'mail_dir_name',
|
||||
'mail_dirs',
|
||||
'contact_headline',
|
||||
'contact_text_1',
|
||||
'contact_text_2',
|
||||
|
|
@ -63,7 +74,7 @@ class TravelCountry extends Model
|
|||
|
||||
];
|
||||
|
||||
protected $casts = ['contact_lands' => 'array', 'contact_emails' => 'array'];
|
||||
protected $casts = ['contact_lands' => 'array', 'mail_dirs'=>'array', 'contact_emails' => 'array'];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
|
|
@ -77,6 +88,16 @@ class TravelCountry extends Model
|
|||
return $this->hasMany(Booking::class, 'travel_country_id', 'id');
|
||||
}
|
||||
|
||||
public function stern_travel_country()
|
||||
{
|
||||
return $this->hasOne(\App\Models\TravelCountry::class, 'crm_id', 'id');
|
||||
}
|
||||
|
||||
public function travel_country_services()
|
||||
{
|
||||
return $this->hasMany(TravelCountryService::class, 'crm_travel_country_id', 'id')->orderBy('pos', 'DESC');
|
||||
}
|
||||
|
||||
public function getCountryLands(){
|
||||
$ret = [];
|
||||
if($this->contact_lands){
|
||||
|
|
@ -90,4 +111,22 @@ class TravelCountry extends Model
|
|||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getMailDirs($id){
|
||||
return isset($this->mail_dirs[$id]) ? $this->mail_dirs[$id] : [];
|
||||
}
|
||||
|
||||
public function getContactLandsModels(){
|
||||
$ret = [];
|
||||
if($this->contact_lands){
|
||||
foreach ($this->contact_lands as $travel_country_id){
|
||||
if($travel_country = TravelCountry::find($travel_country_id)){
|
||||
$ret[$travel_country->id] = $travel_country;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$ret[$this->id] = $this;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @mixin \Eloquent
|
||||
* @property int|null $active
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompany whereActive($value)
|
||||
* @property array|null $contact_emails
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompany whereContactEmails($value)
|
||||
*/
|
||||
class TravelCompany extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -60,6 +60,15 @@ use Illuminate\Support\Str;
|
|||
* @property-read int|null $travel_nationality_requirements_count
|
||||
* @property array|null $contact_emails
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereContactEmails($value)
|
||||
* @property array|null $mail_dirs
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereMailDirs($value)
|
||||
* @property string $mail_dir_name
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereMailDirName($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\GeneralFile[] $general_files
|
||||
* @property-read int|null $general_files_count
|
||||
* @property-read \App\Models\Sym\TravelCountry|null $crm_travel_country
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\TravelCountryService[] $travel_country_services
|
||||
* @property-read int|null $travel_country_services_count
|
||||
*/
|
||||
class TravelCountry extends Model
|
||||
{
|
||||
|
|
@ -68,7 +77,6 @@ class TravelCountry extends Model
|
|||
|
||||
protected $table = 'travel_country';
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'slug',
|
||||
|
|
@ -76,6 +84,8 @@ class TravelCountry extends Model
|
|||
'text_before',
|
||||
'text_after',
|
||||
'contact_lands',
|
||||
'mail_dir_name',
|
||||
'mail_dirs',
|
||||
'contact_headline',
|
||||
'contact_text_1',
|
||||
'contact_text_2',
|
||||
|
|
@ -90,7 +100,7 @@ class TravelCountry extends Model
|
|||
|
||||
];
|
||||
|
||||
protected $casts = ['contact_lands' => 'array', 'contact_emails' => 'array'];
|
||||
protected $casts = ['contact_lands' => 'array', 'mail_dirs' => 'array', 'contact_emails' => 'array'];
|
||||
|
||||
|
||||
public $timestamps = false;
|
||||
|
|
@ -105,11 +115,26 @@ class TravelCountry extends Model
|
|||
return $this->belongsTo('App\Models\Page', 'feedback_page_id', 'id');
|
||||
}
|
||||
|
||||
public function crm_travel_country()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Sym\TravelCountry::class, 'crm_id', 'id');
|
||||
}
|
||||
|
||||
public function travel_nationality_requirements()
|
||||
{
|
||||
return $this->hasMany('App\Models\TravelNationalityRequirement', 'travel_country_id', 'id');
|
||||
}
|
||||
|
||||
public function general_files()
|
||||
{
|
||||
return $this->hasMany(GeneralFile::class, 'travel_country_id', 'id');
|
||||
}
|
||||
|
||||
public function travel_country_services()
|
||||
{
|
||||
return $this->hasMany(TravelCountryService::class, 'travel_country_id', 'id')->orderBy('pos', 'DESC');
|
||||
}
|
||||
|
||||
public function setSlugAttribute( $value ) {
|
||||
if(!isset($value) || $value == ""){
|
||||
$this->attributes['slug'] = Str::slug(pre_slug($this->name), '-');
|
||||
|
|
@ -131,6 +156,23 @@ class TravelCountry extends Model
|
|||
return $ret;
|
||||
}
|
||||
|
||||
public function getMailDirs($id){
|
||||
return isset($this->mail_dirs[$id]) ? $this->mail_dirs[$id] : [];
|
||||
}
|
||||
|
||||
public function getContactLandsModels(){
|
||||
$ret = [];
|
||||
if($this->contact_lands){
|
||||
foreach ($this->contact_lands as $travel_country_id){
|
||||
if($travel_country = TravelCountry::where('crm_id', $contact_land_id)->first()){
|
||||
$ret[$travel_country->id] = $travel_country;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$ret[$this->id] = $this;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
public function getNationalityRequirement($travel_nationality_id){
|
||||
|
||||
$model = TravelNationalityRequirement::where('travel_country_id', $this->id)->where('travel_nationality_id', $travel_nationality_id)->first();
|
||||
|
|
|
|||
85
app/Models/TravelCountryService.php
Normal file
85
app/Models/TravelCountryService.php
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class TravelCountryService
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $travel_country_id
|
||||
* @property int $crm_travel_country
|
||||
* @property string $name
|
||||
* @property string $description
|
||||
* @property bool $active
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property TravelCountry $travel_country
|
||||
* @property Collection|BookingCountryService[] $booking_country_services
|
||||
* @package App\Models
|
||||
* @property int|null $crm_travel_country_id
|
||||
* @property int|null $pos
|
||||
* @property-read int|null $booking_country_services_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService whereCrmTravelCountryId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService whereDescription($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService whereTravelCountryId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class TravelCountryService extends Model
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
|
||||
protected $table = 'travel_country_services';
|
||||
|
||||
protected $casts = [
|
||||
'travel_country_id' => 'int',
|
||||
'crm_travel_country_id' => 'int',
|
||||
'pos' => 'int',
|
||||
'active' => 'bool'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'travel_country_id',
|
||||
'crm_travel_country_id',
|
||||
'name',
|
||||
'description',
|
||||
'pos',
|
||||
'active'
|
||||
];
|
||||
|
||||
protected $status_type = [
|
||||
0 => 'offen',
|
||||
1 => 'erledigt',
|
||||
];
|
||||
|
||||
public function travel_country()
|
||||
{
|
||||
return $this->belongsTo(TravelCountry::class, 'travel_country_id');
|
||||
}
|
||||
|
||||
public function crm_travel_country()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Sym\TravelCountry::class);
|
||||
}
|
||||
|
||||
public function booking_country_services()
|
||||
{
|
||||
return $this->hasMany(BookingCountryService::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -131,4 +131,8 @@ class TravelUser extends Model
|
|||
public function setBirthdayAttribute( $value ) {
|
||||
$this->attributes['birthday'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
|
||||
public function getSalutation(){
|
||||
return $this->salutation_id == 1 ? 'Herr' : 'Frau';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,6 +98,14 @@ use App\Services\Util;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFewo whereUpdatedAt($value)
|
||||
* @property string|null $last_change_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFewo whereLastChangeAt($value)
|
||||
* @property-read \App\Models\CustomerFewoMail|null $customer_fewo_mail_last
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\CustomerFewoMail[] $customer_fewo_mails
|
||||
* @property-read int|null $customer_fewo_mails_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\CustomerFewoMail[] $customer_fewo_mails_sent_at
|
||||
* @property-read int|null $customer_fewo_mails_sent_at_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\TravelUserBookingFile[] $booking_files
|
||||
* @property-read int|null $booking_files_count
|
||||
* @property-read \App\Models\TravelUser $customer
|
||||
*/
|
||||
class TravelUserBookingFewo extends Model
|
||||
{
|
||||
|
|
@ -182,6 +190,11 @@ class TravelUserBookingFewo extends Model
|
|||
'status_text'
|
||||
];
|
||||
|
||||
public static $customer_mail_dirs = [
|
||||
11 => ['name' => 'Entwürfe', 'icon'=>'ion-md-create'],
|
||||
12 => ['name' => 'Papierkorb', 'icon'=>'ion-md-trash'],
|
||||
];
|
||||
|
||||
public function fewo_lodging()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\FewoLodging::class);
|
||||
|
|
@ -202,6 +215,31 @@ class TravelUserBookingFewo extends Model
|
|||
return $this->belongsTo(\App\Models\TravelUser::class);
|
||||
}
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\TravelUser::class, 'travel_user_id');
|
||||
}
|
||||
|
||||
public function booking_files()
|
||||
{
|
||||
return $this->hasMany(TravelUserBookingFile::class, 'travel_user_booking_fewo_id');
|
||||
}
|
||||
|
||||
public function customer_fewo_mails()
|
||||
{
|
||||
return $this->hasMany(CustomerFewoMail::class, 'travel_user_booking_fewo_id', 'id');
|
||||
}
|
||||
|
||||
public function customer_fewo_mails_sent_at()
|
||||
{
|
||||
return $this->hasMany(CustomerFewoMail::class, 'travel_user_booking_fewo_id')->orderBy('sent_at', 'ASC');
|
||||
}
|
||||
|
||||
public function customer_fewo_mail_last()
|
||||
{
|
||||
return $this->hasOne(CustomerFewoMail::class, 'travel_user_booking_fewo_id')->latest();
|
||||
}
|
||||
|
||||
public function getStatuesName(){
|
||||
if(isset(self::$statues[$this->status])){
|
||||
return self::$statues[$this->status];
|
||||
|
|
@ -693,6 +731,16 @@ class TravelUserBookingFewo extends Model
|
|||
return false;
|
||||
}
|
||||
|
||||
public function countCustomerMailsBy($dir, $subdir=false){
|
||||
if($dir === 11){
|
||||
return $this->customer_fewo_mails->where('draft', true)->where('dir', '!=', 12)->count();
|
||||
}
|
||||
if($subdir){
|
||||
return $this->customer_fewo_mails->where('dir', $dir)->where('subdir', $subdir)->count();
|
||||
}
|
||||
return $this->customer_fewo_mails->where('dir', $dir)->count();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
106
app/Models/TravelUserBookingFile.php
Normal file
106
app/Models/TravelUserBookingFile.php
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class TravelUserBookingFile
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $travel_user_booking_fewos
|
||||
* @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 TravelUserBookingFewo $travel_user_booking_fewo
|
||||
* @package App\Models
|
||||
* @property int|null $travel_user_booking_fewo_id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereDir($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereExt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereFilename($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereIdentifier($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereMine($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereOriginalName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereSize($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereTravelUserBookingFewoId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class TravelUserBookingFile extends Model
|
||||
{
|
||||
protected $connection = 'mysql_stern';
|
||||
|
||||
protected $table = 'travel_user_booking_files';
|
||||
|
||||
protected $casts = [
|
||||
'travel_user_booking_fewo_id' => 'int',
|
||||
'size' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'travel_user_booking_fewo_id',
|
||||
'identifier',
|
||||
'filename',
|
||||
'dir',
|
||||
'original_name',
|
||||
'ext',
|
||||
'mine',
|
||||
'size'
|
||||
];
|
||||
|
||||
public static $icon_ext = [
|
||||
'default' => 'fa fa-file',
|
||||
'pdf'=> 'fa fa-file-pdf',
|
||||
'jpg'=> 'fa fa-file-image',
|
||||
'png'=> 'fa fa-file-image',
|
||||
];
|
||||
|
||||
public function travel_user_booking_fewo()
|
||||
{
|
||||
return $this->belongsTo(TravelUserBookingFewo::class, 'travel_user_booking_fewo_id');
|
||||
}
|
||||
|
||||
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_fewo', $do]);
|
||||
}
|
||||
|
||||
public function getPath(){
|
||||
return \Storage::disk('booking_fewo')->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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue