IQ Reisebausteine bis Gruppe

This commit is contained in:
Kevin Adametz 2021-08-06 15:28:57 +02:00
parent 6880c7e989
commit 9baa1a6233
43 changed files with 2206 additions and 24 deletions

View file

@ -44,9 +44,9 @@ class HomeController extends Controller
return redirect('login');
}
$last_booking_notices = BookingNotice::orderBy('edit_at', 'DESC')->orderBy('created_at', 'DESC')->limit(10)->get();
$last_booking_fewo_notices = TravelUserBookingFewoNotice::orderBy('edit_at', 'DESC')->orderBy('created_at', 'DESC')->limit(10)->get();
$last_lead_notices = LeadNotice::orderBy('edit_at', 'DESC')->orderBy('created_at', 'DESC')->limit(10)->get();
$last_booking_notices = BookingNotice::orderBy('updated_at', 'DESC')->limit(10)->get();
$last_booking_fewo_notices = TravelUserBookingFewoNotice::orderBy('updated_at', 'DESC')->limit(10)->get();
$last_lead_notices = LeadNotice::orderBy('updated_at', 'DESC')->limit(10)->get();
$data = [

View file

@ -0,0 +1,31 @@
<?php
namespace App\Http\Controllers\IQ;
use App\Http\Controllers\Controller;
use Request;
use IqContent\LaravelFilemanager\Controllers\LfmController;
class ContentAssetController extends LfmController
{
public function index()
{
$data = [
'models' => [],
'lfm_helper' => $this->helper,
'modal' => false,
];
return view('iq.content.assets.index', $data);
}
public function modal(){
$data = [
'models' => [],
'lfm_helper' => $this->helper,
'modal' => true,
];
return view('iq.content.assets.body', $data);
}
}

View file

@ -0,0 +1,126 @@
<?php
namespace App\Http\Controllers\IQ;
use Request;
use App\Models\IQTravelItemPlace;
use App\Http\Controllers\Controller;
use App\Models\IQTravelGroup;
use App\Models\IQTravelGroupItem;
use App\Repositories\IQ\TravelRepository;
class TravelGroupController extends Controller
{
protected $tavelRepo;
public function __construct(TravelRepository $tavelRepo)
{
$this->middleware('admin');
$this->tavelRepo = $tavelRepo;
}
public function index()
{
$data = [
];
return view('iq.travel.group.index', $data);
}
public function detail($id, $step = false)
{
if($id === "new") {
$model = new IQTravelGroup();
$id = 'new';
$model->active = 1;
}else{
$model = IQTravelGroup::findOrFail($id);
$id = $model->id;
}
$data = [
'model' => $model,
'id' => $id,
];
return view('iq.travel.group.detail', $data);
}
public function store($id)
{
$data = Request::all();
if(isset($data['action'])){
if($data['action'] === 'saveAll'){
$travel_group = $this->tavelRepo->updateTravelGroup($id, $data);
\Session()->flash('alert-save', '1');
return redirect(route('iq_travel_group_detail', [$travel_group->id]));
}
if($data['action'] === 'save-iq_travel_item_group'){
$travel_group_item = $this->tavelRepo->updateTravelGroupItem($id, $data);
\Session()->flash('alert-save', '1');
return redirect(route('iq_travel_group_detail', [$id]));
}
}
return redirect()->back();
}
public function delete($id, $del=false){
if($del === 'i_q_travel_group_item'){
$IQTravelGroupItem = IQTravelGroupItem::findOrFail($id);
$r_id = $IQTravelGroupItem->i_q_travel_group_id;
//TODO check need ???
$IQTravelGroupItem->delete();
\Session()->flash('alert-success', __('Eintrag gelöscht'));
return redirect(route('iq_travel_group_detail', [$r_id]));
}
if($del === 'iq_travel_group'){
$IQTravelGroup = IQTravelGroup::findOrFail($id);
//TODO check need ???
$IQTravelGroup->delete();
\Session()->flash('alert-success', __('Eintrag gelöscht'));
return redirect(route('iq_travel_groups'));
}
return back();
}
public function getTravelGroups()
{
$query = IQTravelGroup::with('i_q_travel_group_items')->with('i_q_travel_group_items.i_q_travel_item')->select('i_q_travel_groups.*');
return \DataTables::eloquent($query)
->addColumn('action_edit', function (IQTravelGroup $iq_travel_group) {
return '<a href="'.route('iq_travel_group_detail', [$iq_travel_group->id]).'" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
})
->addColumn('trave_items', function (IQTravelGroup $iq_travel_group) {
$ret = "";
if($iq_travel_group->i_q_travel_group_items->count()){
foreach($iq_travel_group->i_q_travel_group_items as $i_q_travel_group_item){
$ret .= $i_q_travel_group_item->i_q_travel_item->name;
$ret .= $i_q_travel_group_item->i_q_travel_item->draft_type_id ? ' &nbsp; | &nbsp;<span class="py-0 px-2" style="background-color:'.$i_q_travel_group_item->i_q_travel_item->draft_type->color.'">'.$i_q_travel_group_item->i_q_travel_item->draft_type->name.'</span>' : '';
$ret .= "<br>";
}
$ret = rtrim($ret, '<br>');
}
return $ret;
})
->addColumn('active', function (IQTravelGroup $iq_travel_group) {
return get_active_badge($iq_travel_group->active);
})
->addColumn('action_delete', function (IQTravelGroup $iq_travel_group) {
return '<a href="' . route('iq_travel_group_delete', [$iq_travel_group->id, 'iq_travel_group']) . '" class="btn icon-btn btn-sm btn-danger" onclick="return confirm(\''.__('Really delete entry?').'\');"><span class="fa fa-trash"></span></a>';
})
->orderColumn('id', 'id $1')
->rawColumns(['action_edit', 'id', 'active', 'trave_items', 'action_delete'])
->make(true);
}
}

View file

@ -0,0 +1,136 @@
<?php
namespace App\Http\Controllers\IQ;
use Request;
use App\Models\IQTravelItem;
use App\Models\IQTravelItemPlace;
use App\Http\Controllers\Controller;
use App\Repositories\IQ\TravelRepository;
class TravelItemController extends Controller
{
protected $tavelRepo;
public function __construct(TravelRepository $tavelRepo)
{
$this->middleware('admin');
$this->tavelRepo = $tavelRepo;
}
public function index()
{
$data = [
];
return view('iq.travel.item.index', $data);
}
public function detail($id, $step = false)
{
if($id === "new") {
$model = new IQTravelItem();
$id = 'new';
$model->active = 1;
}else{
$model = IQTravelItem::findOrFail($id);
$id = $model->id;
}
$data = [
'model' => $model,
'id' => $id,
];
return view('iq.travel.item.detail', $data);
}
public function store($id)
{
$data = Request::all();
if(isset($data['action'])){
if($data['action'] === 'saveAll'){
$travel_item = $this->tavelRepo->updateTravelItem($id, $data);
\Session()->flash('alert-save', '1');
return redirect(route('iq_travel_item_detail', [$travel_item->id]));
}
if($data['action'] === 'save-iq_travel_item_place'){
$travel_item_place = $this->tavelRepo->updateTravelItemPlace($id, $data);
\Session()->flash('alert-save', '1');
return redirect(route('iq_travel_item_detail', [$id]));
}
}
return redirect()->back();
}
public function delete($id, $del=false){
if($del === 'i_q_travel_item_place'){
$IQTravelItemPlace = IQTravelItemPlace::findOrFail($id);
$r_id = $IQTravelItemPlace->i_q_travel_item_id;
//TODO check need ???
$IQTravelItemPlace->delete();
\Session()->flash('alert-success', __('Eintrag gelöscht'));
return redirect(route('iq_travel_item_detail', [$r_id]));
}
if($del === 'iq_travel_item'){
$IQTravelItem = IQTravelItem::findOrFail($id);
//TODO check need ???
$IQTravelItem->delete();
\Session()->flash('alert-success', __('Eintrag gelöscht'));
return redirect(route('iq_travel_items'));
}
return back();
}
public function getTravelItems()
{
$query = IQTravelItem::with('draft_type')->with('i_q_travel_item_places')->select('i_q_travel_items.*');
return \DataTables::eloquent($query)
->addColumn('action_edit', function (IQTravelItem $iq_travel_item) {
return '<a href="'.route('iq_travel_item_detail', [$iq_travel_item->id]).'" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
})
->addColumn('draft_type', function (IQTravelItem $iq_travel_item) {
return $iq_travel_item->draft_type ? '<span class="py-1 px-2" style="background-color:'.$iq_travel_item->draft_type->color.'">'.$iq_travel_item->draft_type->name.'</span>' : '';
})
->addColumn('country', function (IQTravelItem $iq_travel_item) {
return $iq_travel_item->travel_country ? $iq_travel_item->travel_country->name : '';
})
->addColumn('trave_places', function (IQTravelItem $iq_travel_item) {
$ret = "";
if($iq_travel_item->i_q_travel_item_places->count()){
foreach($iq_travel_item->i_q_travel_item_places as $i_q_travel_item_place){
$ret .= $i_q_travel_item_place->travel_place->name."<br>";
}
$ret = rtrim($ret, '<br>');
}
return $ret;
})
->addColumn('active', function (IQTravelItem $iq_travel_item) {
return get_active_badge($iq_travel_item->active);
})
/*
->filterColumn('draft_type', function ($query, $keyword) {
if ($keyword != "") {
$query->whereHas('draft_type', function ($q) use ($keyword) {
$q->where("name", 'LIKE', '%' . $keyword . '%');
});
}
})
*/
->addColumn('action_delete', function (IQTravelItem $iq_travel_item) {
return '<a href="' . route('iq_travel_item_delete', [$iq_travel_item->id, 'iq_travel_item']) . '" class="btn icon-btn btn-sm btn-danger" onclick="return confirm(\''.__('Really delete entry?').'\');"><span class="fa fa-trash"></span></a>';
})
->orderColumn('id', 'id $1')
->rawColumns(['action_edit', 'id', 'active', 'draft_type', 'trave_places', 'action_delete'])
->make(true);
}
}

View file

@ -0,0 +1,126 @@
<?php
namespace App\Http\Controllers\IQ;
use Request;
use App\Models\IQTravelItemPlace;
use App\Http\Controllers\Controller;
use App\Models\IQTravelGroup;
use App\Models\IQTravelGroupItem;
use App\Repositories\IQ\TravelRepository;
class TravelProgrammController extends Controller
{
protected $tavelRepo;
public function __construct(TravelRepository $tavelRepo)
{
$this->middleware('admin');
$this->tavelRepo = $tavelRepo;
}
public function index()
{
$data = [
];
return view('iq.travel.programm.index', $data);
}
public function detail($id, $step = false)
{
if($id === "new") {
$model = new IQTravelGroup();
$id = 'new';
$model->active = 1;
}else{
$model = IQTravelGroup::findOrFail($id);
$id = $model->id;
}
$data = [
'model' => $model,
'id' => $id,
];
return view('iq.travel.group.detail', $data);
}
public function store($id)
{
$data = Request::all();
if(isset($data['action'])){
if($data['action'] === 'saveAll'){
$travel_group = $this->tavelRepo->updateTravelGroup($id, $data);
\Session()->flash('alert-save', '1');
return redirect(route('iq_travel_group_detail', [$travel_group->id]));
}
if($data['action'] === 'save-iq_travel_item_group'){
$travel_group_item = $this->tavelRepo->updateTravelGroupItem($id, $data);
\Session()->flash('alert-save', '1');
return redirect(route('iq_travel_group_detail', [$id]));
}
}
return redirect()->back();
}
public function delete($id, $del=false){
if($del === 'i_q_travel_group_item'){
$IQTravelGroupItem = IQTravelGroupItem::findOrFail($id);
$r_id = $IQTravelGroupItem->i_q_travel_group_id;
//TODO check need ???
$IQTravelGroupItem->delete();
\Session()->flash('alert-success', __('Eintrag gelöscht'));
return redirect(route('iq_travel_group_detail', [$r_id]));
}
if($del === 'iq_travel_group'){
$IQTravelGroup = IQTravelGroup::findOrFail($id);
//TODO check need ???
$IQTravelGroup->delete();
\Session()->flash('alert-success', __('Eintrag gelöscht'));
return redirect(route('iq_travel_groups'));
}
return back();
}
public function getTravelGroups()
{
$query = IQTravelGroup::with('i_q_travel_group_items')->with('i_q_travel_group_items.i_q_travel_item')->select('i_q_travel_groups.*');
return \DataTables::eloquent($query)
->addColumn('action_edit', function (IQTravelGroup $iq_travel_group) {
return '<a href="'.route('iq_travel_group_detail', [$iq_travel_group->id]).'" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
})
->addColumn('trave_items', function (IQTravelGroup $iq_travel_group) {
$ret = "";
if($iq_travel_group->i_q_travel_group_items->count()){
foreach($iq_travel_group->i_q_travel_group_items as $i_q_travel_group_item){
$ret .= $i_q_travel_group_item->i_q_travel_item->name;
$ret .= $i_q_travel_group_item->i_q_travel_item->draft_type_id ? ' &nbsp; | &nbsp;<span class="py-0 px-2" style="background-color:'.$i_q_travel_group_item->i_q_travel_item->draft_type->color.'">'.$i_q_travel_group_item->i_q_travel_item->draft_type->name.'</span>' : '';
$ret .= "<br>";
}
$ret = rtrim($ret, '<br>');
}
return $ret;
})
->addColumn('active', function (IQTravelGroup $iq_travel_group) {
return get_active_badge($iq_travel_group->active);
})
->addColumn('action_delete', function (IQTravelGroup $iq_travel_group) {
return '<a href="' . route('iq_travel_group_delete', [$iq_travel_group->id, 'iq_travel_group']) . '" class="btn icon-btn btn-sm btn-danger" onclick="return confirm(\''.__('Really delete entry?').'\');"><span class="fa fa-trash"></span></a>';
})
->orderColumn('id', 'id $1')
->rawColumns(['action_edit', 'id', 'active', 'trave_items', 'action_delete'])
->make(true);
}
}

View file

@ -2,14 +2,16 @@
namespace App\Http\Controllers;
use Request;
use App\Models\GeneralFile;
use App\Models\IQContentSite;
use App\Models\ServiceProviderService;
use App\Models\TravelCompanyService;
use App\Models\TravelCountry;
use App\Models\IQTravelGroupItem;
use App\Models\IQTravelItemPlace;
use App\Models\TravelCompanyService;
use App\Models\TravelCountryService;
use App\Models\ServiceProviderService;
use App\Repositories\GeneralFileRepository;
use Request;
class ModalController extends Controller
{
@ -70,6 +72,29 @@ class ModalController extends Controller
}
$ret = view("admin.modal.provider-service", compact('data', 'value'))->render();
}
if($data['action'] === 'modal-iq_travel_item-place'){
if($data['id'] === 'new'){
$value = new IQTravelItemPlace();
$value->pos = 0;
}else{
$value = IQTravelItemPlace::find($data['id']);
}
$ret = view("admin.modal.iq_travel_item-place", compact('data', 'value'))->render();
}
if($data['action'] === 'modal-iq_travel_item-group'){
if($data['id'] === 'new'){
$value = new IQTravelGroupItem();
$value->pos = 0;
}else{
$value = IQTravelGroupItem::find($data['id']);
}
$ret = view("admin.modal.iq_travel_group-item", compact('data', 'value'))->render();
}
}
return response()->json(['response' => $data, 'html'=>$ret, 'status'=>$status]);
}

View file

@ -0,0 +1,58 @@
<?php
namespace App\Http\Controllers\Settings;
use App\Http\Controllers\Controller;
use App\Models\IQContentCategory;
use App\Models\TravelPlace;
use App\Services\Util;
use Request;
class TravelPlaceController extends Controller
{
public function __construct()
{
$this->middleware('admin');
}
public function index($step = false)
{
$data = [
'travel_places' => TravelPlace::all(),
];
return view('settings.place.index', $data);
}
public function update(){
$data = Request::all();
$data['active'] = isset($data['active']) ? true : false;
if($data['id'] === "new"){
$model = TravelPlace::create($data);
}else{
$model = TravelPlace::find($data['id']);
$model->fill($data);
$model->save();
}
\Session()->flash('alert-save', '1');
return redirect(route('admin_settings_travel_places'));
}
public function delete($id){
//TODO check ist linked
$model = TravelPlace::findOrFail($id);
$model->delete();
\Session()->flash('alert-success', 'Eintrag gelöscht');
return redirect()->back();
}
}

View file

@ -533,7 +533,7 @@ class Booking extends Model
public function booking_notices()
{
return $this->hasMany(BookingNotice::class, 'booking_id')->orderBy('created_at', 'DESC');
return $this->hasMany(BookingNotice::class, 'booking_id')->orderBy('updated_at', 'DESC');
}
public function booking_strono()

View file

@ -0,0 +1,107 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use App\Services\Util;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Collection;
/**
* Class IQTravelGroup
*
* @property int $id
* @property string $name
* @property string $description
* @property string $highlights
* @property int $days_start
* @property int $days_duration
* @property int $min_persons
* @property float $price_adult
* @property float $price_children
* @property int $pos
* @property bool $active
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @property Collection|IQTravelGroupItem[] $i_q_travel_group_items
*
* @package App\Models
*/
class IQTravelGroup extends Model
{
protected $connection = 'mysql_stern';
protected $table = 'i_q_travel_groups';
protected $casts = [
'days_start' => 'int',
'days_duration' => 'int',
'min_persons' => 'int',
'price_adult' => 'float',
'price_children' => 'float',
'pos' => 'int',
'active' => 'bool'
];
protected $fillable = [
'name',
'description',
'highlights',
'days_start',
'days_duration',
'min_persons',
'price_adult',
'price_children',
'pos',
'active'
];
public function i_q_travel_group_items()
{
return $this->hasMany(IQTravelGroupItem::class)->orderBy('pos', 'DESC');
}
//price_adult
public function getPriceAdultAttribute()
{
return isset($this->attributes['price_adult']) ? Util::_number_format($this->attributes['price_adult']) : null;
}
public function setPriceAdultAttribute($value)
{
$this->attributes['price_adult'] = $value ? Util::_clean_float($value) : null;
}
public function getPriceAdultRaw()
{
return isset($this->attributes['price_adult']) ? $this->attributes['price_adult'] : 0;
}
public function setPriceAdultRaw($value)
{
return $this->attributes['price_adult'] = $value;
}
//price_children
public function getPriceChildrenAttribute()
{
return isset($this->attributes['price_children']) ? Util::_number_format($this->attributes['price_children']) : null;
}
public function setPriceChildrenAttribute($value)
{
$this->attributes['price_children'] = $value ? Util::_clean_float($value) : null;
}
public function getPriceChildrenRaw()
{
return isset($this->attributes['price_children']) ? $this->attributes['price_children'] : 0;
}
public function setPriceChildrenRaw($value)
{
return $this->attributes['price_children'] = $value;
}
}

View file

@ -0,0 +1,55 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class IQTravelGroupItem
*
* @property int $id
* @property int $i_q_travel_group_id
* @property int $i_q_travel_item_id
* @property int $pos
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @property IQTravelGroup $i_q_travel_group
* @property IQTravelItem $i_q_travel_item
*
* @package App\Models
*/
class IQTravelGroupItem extends Model
{
protected $connection = 'mysql_stern';
protected $table = 'i_q_travel_group_items';
protected $casts = [
'i_q_travel_group_id' => 'int',
'i_q_travel_item_id' => 'int',
'pos' => 'int',
];
protected $fillable = [
'i_q_travel_group_id',
'i_q_travel_item_id',
'pos',
];
public function i_q_travel_group()
{
return $this->belongsTo(IQTravelGroup::class);
}
public function i_q_travel_item()
{
return $this->belongsTo(IQTravelItem::class);
}
}

131
app/Models/IQTravelItem.php Normal file
View file

@ -0,0 +1,131 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use App\Services\Util;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Collection;
/**
* Class IQTravelItem
*
* @property int $id
* @property string $name
* @property string $description
* @property string $highlights
* @property int $draft_type_id
* @property int $travel_country_id
* @property int $days_start
* @property int $days_duration
* @property int $min_persons
* @property float $price_adult
* @property float $price_children
* @property int $pos
* @property bool $active
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @property TravelCountry $travel_country
* @property Collection|IQTravelGroupItem[] $i_q_travel_group_items
* @property Collection|IQTravelItemPlace[] $i_q_travel_item_places
*
* @package App\Models
*/
class IQTravelItem extends Model
{
protected $connection = 'mysql_stern';
protected $table = 'i_q_travel_items';
protected $casts = [
'draft_type_id' => 'int',
'travel_country_id' => 'int',
'days_start' => 'int',
'days_duration' => 'int',
'min_persons' => 'int',
'price_adult' => 'float',
'price_children' => 'float',
'pos' => 'int',
'active' => 'bool'
];
protected $fillable = [
'name',
'description',
'highlights',
'draft_type_id',
'travel_country_id',
'days_start',
'days_duration',
'min_persons',
'price_adult',
'price_children',
'pos',
'active'
];
public function travel_country()
{
return $this->belongsTo(TravelCountry::class);
}
public function i_q_travel_group_items()
{
return $this->hasMany(IQTravelGroupItem::class);
}
public function i_q_travel_item_places()
{
return $this->hasMany(IQTravelItemPlace::class)->orderBy('pos', 'DESC');
}
public function draft_type()
{
return $this->belongsTo(DraftType::class, 'draft_type_id');
}
//price_adult
public function getPriceAdultAttribute()
{
return isset($this->attributes['price_adult']) ? Util::_number_format($this->attributes['price_adult']) : null;
}
public function setPriceAdultAttribute($value)
{
$this->attributes['price_adult'] = $value ? Util::_clean_float($value) : null;
}
public function getPriceAdultRaw()
{
return isset($this->attributes['price_adult']) ? $this->attributes['price_adult'] : 0;
}
public function setPriceAdultRaw($value)
{
return $this->attributes['price_adult'] = $value;
}
//price_children
public function getPriceChildrenAttribute()
{
return isset($this->attributes['price_children']) ? Util::_number_format($this->attributes['price_children']) : null;
}
public function setPriceChildrenAttribute($value)
{
$this->attributes['price_children'] = $value ? Util::_clean_float($value) : null;
}
public function getPriceChildrenRaw()
{
return isset($this->attributes['price_children']) ? $this->attributes['price_children'] : 0;
}
public function setPriceChildrenRaw($value)
{
return $this->attributes['price_children'] = $value;
}
}

View file

@ -0,0 +1,54 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class IQTravelItemPlace
*
* @property int $id
* @property int $i_q_travel_item_id
* @property int $travel_place_id
* @property int $pos
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @property IQTravelItem $i_q_travel_item
* @property TravelPlace $travel_place
*
* @package App\Models
*/
class IQTravelItemPlace extends Model
{
protected $connection = 'mysql_stern';
protected $table = 'i_q_travel_item_places';
protected $casts = [
'i_q_travel_item_id' => 'int',
'travel_place_id' => 'int',
'pos' => 'int',
];
protected $fillable = [
'i_q_travel_item_id',
'travel_place_id',
'pos',
];
public function i_q_travel_item()
{
return $this->belongsTo(IQTravelItem::class);
}
public function travel_place()
{
return $this->belongsTo(TravelPlace::class);
}
}

View file

@ -277,7 +277,7 @@ class Lead extends Model
public function lead_notices()
{
return $this->hasMany(LeadNotice::class, 'lead_id')->orderBy('created_at', 'DESC');
return $this->hasMany(LeadNotice::class, 'lead_id')->orderBy('updated_at', 'DESC');
}

View file

@ -166,7 +166,7 @@ class TravelCountry extends Model
public function getContactLandsModels(){
$ret = [];
if($this->contact_lands){
foreach ($this->contact_lands as $travel_country_id){
foreach ($this->contact_lands as $contact_land_id){
if($travel_country = TravelCountry::where('crm_id', $contact_land_id)->first()){
$ret[$travel_country->id] = $travel_country;
}

View file

@ -0,0 +1,54 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class TravelPlace
*
* @property int $id
* @property string $name
* @property string $description
* @property int $travel_country_id
* @property float $latitude
* @property float $longitude
* @property bool $active
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @property TravelCountry $travel_country
*
* @package App\Models
*/
class TravelPlace extends Model
{
protected $connection = 'mysql_stern';
protected $table = 'travel_places';
protected $casts = [
'travel_country_id' => 'int',
'latitude' => 'float',
'longitude' => 'float',
'active' => 'bool'
];
protected $fillable = [
'name',
'description',
'travel_country_id',
'latitude',
'longitude',
'active'
];
public function travel_country()
{
return $this->belongsTo(TravelCountry::class);
}
}

View file

@ -253,7 +253,7 @@ class TravelUserBookingFewo extends Model
public function booking_fewo_notices()
{
return $this->hasMany(TravelUserBookingFewoNotice::class, 'travel_user_booking_fewo_id')->orderBy('created_at', 'DESC');
return $this->hasMany(TravelUserBookingFewoNotice::class, 'travel_user_booking_fewo_id')->orderBy('updated_at', 'DESC');
}
public function getStatuesName(){

View file

@ -46,7 +46,7 @@ class ContentSiteRepository extends BaseRepository {
$site_field = false;
// $site_field = IQContentSiteField::getSiteFieldOrNew($contentSite->id, $model_field->id);
//new
if(!$site_field->id){
/*if(!$site_field->id){
$site_field->site_id = $contentSite->id;
$site_field->model_field_id = $model_field->id;
$site_field->field = $model_field->field;
@ -57,7 +57,7 @@ class ContentSiteRepository extends BaseRepository {
}else{
}
}*/
$ret[] = $site_field;
}

View file

@ -0,0 +1,89 @@
<?php
namespace App\Repositories\IQ;
use App\Models\IQTravelGroup;
use App\Models\IQTravelGroupItem;
use App\Models\IQTravelItem;
use App\Models\IQTravelItemPlace;
use App\Repositories\BaseRepository;
class TravelRepository extends BaseRepository {
public function __construct()
{
$this->model = null;
}
public function updateTravelGroup($id, $data)
{
if($id == "new"){
$this->model = IQTravelGroup::create($data);
}
else{
$this->model = IQTravelGroup::findOrFail($id);
$this->model->fill($data);
$this->model->save();
}
return $this->model;
}
public function updateTravelGroupItem($id, $data)
{
$data['pos'] = $data['pos'] ? intval($data['pos']) : 0;
$data['i_q_travel_group_id'] = $data['iq_travel_group_id'];
if($data['iq_travel_group_item_id'] == "new"){
$this->model = IQTravelGroupItem::create($data);
}
else{
$this->model = IQTravelGroupItem::findOrFail($data['iq_travel_group_item_id']);
$this->model->fill($data);
$this->model->save();
}
return $this->model;
}
public function updateTravelItem($id, $data)
{
$data['draft_type_id'] = $data['draft_type_id'] ? $data['draft_type_id'] : null;
$data['travel_country_id'] = $data['travel_country_id'] ? $data['travel_country_id'] : null;
if($id == "new"){
$this->model = IQTravelItem::create($data);
}
else{
$this->model = IQTravelItem::findOrFail($id);
$this->model->fill($data);
$this->model->save();
}
return $this->model;
}
public function updateTravelItemPlace($id, $data)
{
$data['pos'] = $data['pos'] ? intval($data['pos']) : 0;
$data['i_q_travel_item_id'] = $data['iq_travel_item_id'];
if($data['iq_travel_item_place_id'] == "new"){
$this->model = IQTravelItemPlace::create($data);
}
else{
$this->model = IQTravelItemPlace::findOrFail($data['iq_travel_item_place_id']);
$this->model->fill($data);
$this->model->save();
}
return $this->model;
}
}

View file

@ -9,12 +9,14 @@ use App\Models\Draft;
use App\Models\DraftType;
use App\Models\FewoLodging;
use App\Models\Insurance;
use App\Models\IQTravelItem;
use App\Models\TravelBookingFewoChannel;
use App\Models\TravelClass;
use App\Models\TravelCompany;
use App\Models\TravelCountry;
use App\Models\TravelGuide;
use App\Models\TravelNationality;
use App\Models\TravelPlace;
use App\Models\TravelProgram;
use App\Models\TravelUser;
use Form;
@ -238,7 +240,7 @@ class HTMLHelper
return $ret;
}
public static function getTravelCountriesOptions($countryId = false){
public static function getTravelCountriesOptions($countryId = false, $crm = true){
$checked = [];
if($countryId){
!is_array($countryId) ? $checked = array($countryId) : $checked = $countryId;
@ -246,15 +248,15 @@ class HTMLHelper
$options = TravelCountry::where('active_backend',1)->get();
$ret = '';
foreach ($options as $option){
$attr = (in_array($option->crm_id, $checked)) ? 'selected="selected"' : '';
$ret .= '<option value="'.$option->crm_id.'" '.$attr.'>'.$option->name.'</option>\n';
$id = $crm ? $option->crm_id : $option->id;
$attr = (in_array($id, $checked)) ? 'selected="selected"' : '';
$ret .= '<option value="'.$id.'" '.$attr.'>'.$option->name.'</option>\n';
}
return $ret;
}
public static function getTravelUserOptions($id = false, $order = "ASC", $empty=false){
$options = TravelUser::orderBy('id', $order)->get();
$ret = '';
if($empty){
$ret = '<option value="">Bitte wählen</option>\n';
@ -267,6 +269,33 @@ class HTMLHelper
return $ret;
}
public static function getTravelPlaceOptions($id = false, $order = "ASC", $empty=false){
$options = TravelPlace::where('active',1)->orderBy('id', $order)->get();
$ret = '';
if($empty){
$ret = '<option value="">Bitte wählen</option>\n';
}
foreach ($options as $option){
$attr = ($option->id === $id) ? 'selected="selected"' : '';
$ret .= '<option value="'.$option->id.'" '.$attr.'>'.$option->name.'</option>\n';
}
return $ret;
}
public static function getIQTravelItemsOptions($id = false, $order = "ASC", $empty=false){
$options = IQTravelItem::where('active',1)->orderBy('id', $order)->get();
$ret = '';
if($empty){
$ret = '<option value="">Bitte wählen</option>\n';
}
foreach ($options as $option){
$attr = ($option->id === $id) ? 'selected="selected"' : '';
$ret .= '<option value="'.$option->id.'" '.$attr.'>'.$option->name.'</option>\n';
}
return $ret;
}
public static function getCustomerMailDirsOptions(CMSContent $customer_mail_dir, $checked = []){
//$checked = [];
$model = $customer_mail_dir->getArrayContent('model');

View file

@ -3,6 +3,7 @@ namespace App\Services;
use App\Models\Branch;
use App\Models\Status;
use App\Models\DraftType;
use App\Models\Salutation;
use App\Models\SfGuardUser;
use App\Models\TravelAgenda;
@ -75,6 +76,11 @@ class Model
$TravelNationality = TravelNationality::where('active', true)->orderBy('name')->get()->pluck('name', 'id');
return $emtpy ? $TravelNationality->prepend('-', 0) : $TravelNationality;
}
public static function getDraftTypeArray($emtpy = false){
$DraftType = DraftType::where('active', true)->orderByDesc('pos')->get()->pluck('name', 'id');
return $emtpy ? $DraftType->prepend('-', 0) : $DraftType;
}