travel guide
This commit is contained in:
parent
346a7427a5
commit
a1ca534f55
26 changed files with 5788 additions and 3191 deletions
231
app/Http/Controllers/CMS/CMSTravelGuideController.php
Executable file
231
app/Http/Controllers/CMS/CMSTravelGuideController.php
Executable file
|
|
@ -0,0 +1,231 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\CMS;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\TravelGuide;
|
||||
use App\Models\TravelPageGuide;
|
||||
use AppBundle\Util;
|
||||
use Gregwar\Image\Image;
|
||||
use Illuminate\Http\Request;
|
||||
use Input;
|
||||
use Validator;
|
||||
|
||||
class CMSTravelGuideController extends Controller
|
||||
{
|
||||
|
||||
/*
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
/*
|
||||
$alls = TravelGuide::all();
|
||||
foreach ($alls as $all){
|
||||
$all->full_text = $this->cleanHTML($all->full_text);
|
||||
$all->save();
|
||||
}
|
||||
*/
|
||||
$data = [
|
||||
'travel_guides' => TravelGuide::all(),
|
||||
];
|
||||
return view('cms.travel_guide.index', $data);
|
||||
|
||||
}
|
||||
|
||||
public function page()
|
||||
{
|
||||
$data = [
|
||||
'travel_guide_pages' => TravelPageGuide::getPageGuides(),
|
||||
];
|
||||
return view('cms.travel_guide.page', $data);
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
if($id == "new") {
|
||||
$model = new TravelGuide();
|
||||
$id = 'new';
|
||||
$model->active = 1;
|
||||
|
||||
}else{
|
||||
$model = TravelGuide::findOrFail($id);
|
||||
$id = $model->id;
|
||||
}
|
||||
|
||||
if(Input::get('clean') == "true"){
|
||||
$model->full_text = $this->cleanHTML($model->full_text);
|
||||
|
||||
}
|
||||
|
||||
$data = [
|
||||
'travel_guide' => $model,
|
||||
'id' => $id,
|
||||
];
|
||||
return view('cms.travel_guide.detail', $data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function cleanHTML($html)
|
||||
{
|
||||
|
||||
|
||||
$html = str_replace('font-size: 14px;', ' ', $html);
|
||||
$html = str_replace('font-weight: lighter; ', ' ', $html);
|
||||
$html = str_replace('font-family: Helvetica, Arial, sans-serif; ', ' ', $html);
|
||||
$html = str_replace('font-family: Verdana, sans-serif; ', ' ', $html);
|
||||
$html = str_replace('color: rgb(60, 60, 60); ', ' ', $html);
|
||||
$html = str_replace(' style=" padding: 0px; margin-right: 0px; margin-left: 0px; margin-bottom: 20px !important; line-height: 20px !important;"', ' ', $html);
|
||||
$html = str_replace('property="article"', ' ', $html);
|
||||
$html = str_replace(' ', ' ', $html);
|
||||
$html = str_replace('https://www.aegypten-online.de', 'https://www.sterntours.de', $html);
|
||||
|
||||
$dom = new \DOMDocument('1.0', 'utf-8');
|
||||
@$dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
|
||||
|
||||
$removeFullTags = ['span', 'a'];
|
||||
|
||||
foreach ($removeFullTags as $removeFullTag){
|
||||
$domElemsToRemove = [];
|
||||
$elements = $dom->getElementsByTagName($removeFullTag);
|
||||
foreach ($elements as $element) {
|
||||
$domElemsToRemove[] = $element;
|
||||
|
||||
}
|
||||
foreach ($domElemsToRemove as $domElem) {
|
||||
if($removeFullTag == 'span' && strpos($domElem->getAttribute('style'), 'font-weight: 700') !== false){
|
||||
$new_node = $dom->createTextNode("<strong>".$domElem->nodeValue."</strong>");
|
||||
}else{
|
||||
$new_node = $dom->createTextNode($domElem->nodeValue);
|
||||
}
|
||||
$domElem->parentNode->replaceChild($new_node, $domElem);
|
||||
}
|
||||
}
|
||||
$removeStyleTags = ['ul', 'li', 'h1', 'h2', 'br'];
|
||||
foreach ($removeStyleTags as $removeStyleTag){
|
||||
$elements = $dom->getElementsByTagName($removeStyleTag);
|
||||
foreach ($elements as $element) {
|
||||
$element->removeAttribute('style');
|
||||
}
|
||||
}
|
||||
$html = $dom->saveHTML();
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function pageDetail($id)
|
||||
{
|
||||
if($id == "new") {
|
||||
/* $model = new TravelGuide();
|
||||
$id = 'new';
|
||||
$model->active = 1;
|
||||
*/
|
||||
|
||||
}else{
|
||||
$model = TravelPageGuide::findOrFail($id);
|
||||
$id = $model->id;
|
||||
}
|
||||
$data = [
|
||||
'travel_guide_page' => $model,
|
||||
'id' => $id,
|
||||
];
|
||||
return view('cms.travel_guide.page_detail', $data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function store($id)
|
||||
{
|
||||
$data = Input::all();
|
||||
$data['active'] = isset($data['active']) ? true : false;
|
||||
$data['scope'] = isset($data['scope']) ? true : false;
|
||||
$rules = array(
|
||||
'name' => 'required',
|
||||
);
|
||||
if($id != "new") {
|
||||
$model = TravelGuide::findOrFail($id);
|
||||
|
||||
$rules = array(
|
||||
'name' => 'required',
|
||||
'slug' => 'unique:mysql_stern.travel_guides,slug,'.$model->id,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator);
|
||||
}
|
||||
|
||||
if($id == "new") {
|
||||
$model = TravelGuide::create($data);
|
||||
}else{
|
||||
$model = TravelGuide::findOrFail($id);
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('cms_travel_guide_detail', [$model->id]));
|
||||
|
||||
}
|
||||
|
||||
public function pageStore($id)
|
||||
{
|
||||
$data = Input::all();
|
||||
$data['status'] = isset($data['status']) ? 1 : 0;
|
||||
$data['show_in_navi'] = isset($data['show_in_navi']) ? 1 : 0;
|
||||
$rules = array(
|
||||
'title' => 'required',
|
||||
);
|
||||
|
||||
if($id != "new") {
|
||||
$model = TravelPageGuide::findOrFail($id);
|
||||
|
||||
$rules = array(
|
||||
'title' => 'required',
|
||||
// 'slug' => 'unique:mysql_stern.travel_guides,slug,'.$model->id,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator);
|
||||
}
|
||||
|
||||
if($id == "new") {
|
||||
$model = TravelPageGuide::create($data);
|
||||
}else{
|
||||
$model = TravelPageGuide::findOrFail($id);
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('cms_travel_guide_page_detail', [$model->id]));
|
||||
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$model = TravelGuide::findOrFail($id);
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', __('Eintrag Reisemagazin gelöscht'));
|
||||
return redirect(route('cms_travel_guide_content'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\CMS;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\TravelMagazine;
|
||||
use Input;
|
||||
use Validator;
|
||||
|
||||
class CMSTravelMagazineController extends Controller
|
||||
{
|
||||
|
||||
/*
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
'travel_magazines' => TravelMagazine::all(),
|
||||
];
|
||||
return view('cms.travel_magazine.index', $data);
|
||||
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
if($id == "new") {
|
||||
$model = new TravelMagazine();
|
||||
$id = 'new';
|
||||
$model->active = 1;
|
||||
|
||||
}else{
|
||||
$model = TravelMagazine::findOrFail($id);
|
||||
$id = $model->id;
|
||||
}
|
||||
$data = [
|
||||
'travel_magazine' => $model,
|
||||
'id' => $id,
|
||||
];
|
||||
return view('cms.travel_magazine.detail', $data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function store($id)
|
||||
{
|
||||
$data = Input::all();
|
||||
$data['active'] = isset($data['active']) ? true : false;
|
||||
$data['scope'] = isset($data['scope']) ? true : false;
|
||||
$rules = array(
|
||||
'name' => 'required',
|
||||
);
|
||||
if($id != "new") {
|
||||
$model = TravelMagazine::findOrFail($id);
|
||||
|
||||
$rules = array(
|
||||
'name' => 'required',
|
||||
'slug' => 'unique:mysql_stern.travel_magazines,slug,'.$model->id,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator);
|
||||
}
|
||||
|
||||
if($id == "new") {
|
||||
$model = TravelMagazine::create($data);
|
||||
}else{
|
||||
$model = TravelMagazine::findOrFail($id);
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('cms_travel_magazine_detail', [$model->id]));
|
||||
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$model = TravelMagazine::findOrFail($id);
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', __('Eintrag Reisemagazin gelöscht'));
|
||||
return redirect(route('cms_travel_magazine'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -21,23 +21,23 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property int $active
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine findSimilarSlugs($attribute, $config, $slug)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereFullText($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereMetaDescription($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereMetaKeywords($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereMetaTitle($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereScope($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereText($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelMagazine whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide findSimilarSlugs($attribute, $config, $slug)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereFullText($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereMetaDescription($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereMetaKeywords($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereMetaTitle($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereScope($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereText($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class TravelMagazine extends Model
|
||||
class TravelGuide extends Model
|
||||
{
|
||||
|
||||
use Sluggable;
|
||||
|
|
@ -46,7 +46,7 @@ class TravelMagazine extends Model
|
|||
//use the connection to sec. Datebase sterntours
|
||||
protected $connection = 'mysql_stern';
|
||||
|
||||
protected $table = 'travel_magazines';
|
||||
protected $table = 'travel_guides';
|
||||
|
||||
|
||||
protected static $scopes = [
|
||||
|
|
@ -76,6 +76,7 @@ class TravelMagazine extends Model
|
|||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getScopeName($key = 0){
|
||||
return isset(self::$scopes[$key]) ? self::$scopes[$key] : '';
|
||||
}
|
||||
63
app/Models/TravelPageGuide.php
Normal file
63
app/Models/TravelPageGuide.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TravelPageGuide extends Model
|
||||
{
|
||||
protected $connection = 'mysql_stern';
|
||||
|
||||
protected $table = 'page';
|
||||
|
||||
protected $fillable = [
|
||||
'slug',
|
||||
'status',
|
||||
'show_in_navi',
|
||||
'order',
|
||||
'title',
|
||||
'pagetitle',
|
||||
'description',
|
||||
'keywords',
|
||||
'content_new',
|
||||
'travel_guide_content_id',
|
||||
];
|
||||
|
||||
|
||||
private static $pages = [];
|
||||
|
||||
public static function getPageGuides($setKey = false){
|
||||
$values = self::where('model', 'travel_guide')->where('lvl', 1)->orderBy('order')->get();
|
||||
|
||||
foreach ($values as $value){
|
||||
self::$pages[] = $value;
|
||||
|
||||
$value->checkChilds();
|
||||
if($childs = $value->getChilds()){
|
||||
foreach ($childs as $child){
|
||||
$ret[] = $child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return self::$pages;
|
||||
}
|
||||
|
||||
public function checkChilds(){
|
||||
if($childs = $this->getChilds()){
|
||||
foreach ($childs as $child){
|
||||
self::$pages[] = $child;
|
||||
$child->checkChilds();
|
||||
}
|
||||
}
|
||||
}
|
||||
public function getChilds(){
|
||||
return TravelPageGuide::where('parent_id', $this->id)->where('lvl', ($this->lvl+1))->orderBy('order')->get();
|
||||
}
|
||||
|
||||
public function getContentNewAttribute()
|
||||
{
|
||||
return isset($this->attributes['content_new']) ? $this->attributes['content_new'] : $this->attributes['content'];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Storage;
|
||||
use App\Services\Util;
|
||||
|
|
@ -397,6 +397,30 @@ class TravelUserBookingFewo extends Model
|
|||
return number_format(($total_pay - $first_pay + $this->getPriceDepositRaw()), 2, ',', '.');
|
||||
}
|
||||
|
||||
public function getPriceTravelTotalPay(){
|
||||
if($this->attributes['price_travel'] == 0){
|
||||
return 0;
|
||||
}
|
||||
$total_pay = ($this->getPriceTravelTotalRaw() + $this->getPriceServiceRaw());
|
||||
return number_format(($total_pay + $this->getPriceDepositRaw()), 2, ',', '.');
|
||||
}
|
||||
|
||||
public function getDepartureInDays()
|
||||
{
|
||||
if(isset($this->attributes['from_date'])){
|
||||
return Carbon::now()->diffInDays(Carbon::parse($this->attributes['from_date']), false);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function isFromDateAfterDays($days = 30){
|
||||
if(($this->getDepartureInDays() - $days) > 0){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getBookingDateYear(){
|
||||
return Carbon::parse($this->booking_date)->format('Y');
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use App\Models\Interest;
|
|||
use App\Models\TravelBookingFewoChannel;
|
||||
use App\Models\TravelClass;
|
||||
use App\Models\TravelCountry;
|
||||
use App\Models\TravelGuide;
|
||||
use App\Models\TravelNationality;
|
||||
use App\Models\TravelProgram;
|
||||
use App\Models\TravelUser;
|
||||
|
|
@ -212,6 +213,16 @@ class HTMLHelper
|
|||
return $ret;
|
||||
}
|
||||
|
||||
public static function getTravelGuideOptions($id = false){
|
||||
$options = TravelGuide::where('active',1)->get();
|
||||
$ret = '<option value="">keinen Inhalt</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 getWeekdaysOptions($programId = false, $weekdays = []){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue