Natinality, Country, Agenda, search Request. CMS
Magazine Content
This commit is contained in:
parent
30d5ca3b44
commit
aebfb0586a
72 changed files with 4636 additions and 590 deletions
97
app/Http/Controllers/CMS/CMSContentController.php
Executable file
97
app/Http/Controllers/CMS/CMSContentController.php
Executable file
|
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\CMS;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\CMSContent;
|
||||
use Input;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
|
||||
class CMSContentController extends Controller
|
||||
{
|
||||
|
||||
/*
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
'contents' => CMSContent::all()->sortByDesc('id')
|
||||
];
|
||||
return view('cms.content.index', $data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function store()
|
||||
{
|
||||
$data = Input::all();
|
||||
$rules = array(
|
||||
'name' => 'required',
|
||||
'field' => 'required',
|
||||
);
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator);
|
||||
}
|
||||
|
||||
if($data['id'] == "new"){
|
||||
CMSContent::create($data);
|
||||
}else{
|
||||
$model = CMSContent::find($data['id']);
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
}
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('cms_content'));
|
||||
}
|
||||
|
||||
|
||||
public function loadModal()
|
||||
{
|
||||
if(Request::ajax()){
|
||||
$data = Input::all();
|
||||
$returnHTML = "";
|
||||
if(isset($data['model']) && isset($data['id']) ){
|
||||
if($data['model'] == 'content'){
|
||||
if($data['id'] == "new"){
|
||||
$value = new CMSContent();
|
||||
}else {
|
||||
$value = CMSContent::find($data['id']);
|
||||
}
|
||||
$returnHTML = view("cms.content.modal", compact('data','value') )->render();
|
||||
}
|
||||
|
||||
}
|
||||
return response()->json(['response' => $data, 'html'=>$returnHTML]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function delete($id){
|
||||
$content = CMSContent::findOrFail($id);
|
||||
$content->delete();
|
||||
\Session()->flash('alert-success', __('Content gelöscht'));
|
||||
return redirect(route('cms_content'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
102
app/Http/Controllers/CMS/CMSTravelMagazineController.php
Executable file
102
app/Http/Controllers/CMS/CMSTravelMagazineController.php
Executable file
|
|
@ -0,0 +1,102 @@
|
|||
<?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'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -4,8 +4,11 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Models\Booking;
|
||||
use App\Services\HTMLHelper;
|
||||
use Carbon\Carbon;
|
||||
use Composer\DependencyResolver\Request;
|
||||
use DataTables;
|
||||
use App\User;
|
||||
use Input;
|
||||
|
||||
class DataTableController extends Controller
|
||||
{
|
||||
|
|
@ -72,7 +75,7 @@ class DataTableController extends Controller
|
|||
public function getBookings()
|
||||
{
|
||||
//confirmation_code_remider is delete 2
|
||||
$query = Booking::orderBy("id", "DESC");
|
||||
$query = Booking::query();
|
||||
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
|
|
@ -80,9 +83,195 @@ class DataTableController extends Controller
|
|||
return '<a href="' . route('booking_detail', [$booking->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('id', function (Booking $booking) {
|
||||
return '<a href="' . route('booking_detail', [$booking->id]) . '" data-id="'.$booking->id.'">'.$booking->id.'</a>';
|
||||
return '<a data-order="'.$booking->id.'" href="' . route('booking_detail', [$booking->id]) . '" data-id="'.$booking->id.'">'.$booking->id.'</a>';
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->rawColumns(['action_edit', 'id'])
|
||||
|
||||
->make(true);
|
||||
}
|
||||
|
||||
public function getRequests()
|
||||
{
|
||||
|
||||
$query = Booking::where('lead_id', '!=', NULL);
|
||||
|
||||
if(Input::get('full_firstname_search') != ""){
|
||||
$query->where('participant_firstname', 'LIKE', '%'.Input::get('full_firstname_search').'%');
|
||||
}
|
||||
|
||||
if(Input::get('full_lastname_search') != ""){
|
||||
$query->where('participant_name', 'LIKE', '%'.Input::get('full_lastname_search').'%');
|
||||
}
|
||||
|
||||
// $query->where('end_date', '<=', $now);
|
||||
|
||||
if(Input::get('travel_option_search')){
|
||||
$now = Carbon::now();
|
||||
|
||||
|
||||
switch (Input::get('travel_option_search')){
|
||||
case 'before_2':
|
||||
$query->whereBetween('start_date', [Carbon::now()->modify('-2 month'), $now]);
|
||||
|
||||
break;
|
||||
case 'brefore_1':
|
||||
$query->whereBetween('start_date', [Carbon::now()->modify('-1 month'), $now]);
|
||||
|
||||
break;
|
||||
case 'on_site':
|
||||
$query->where('start_date', '<=', $now);
|
||||
$query->where('end_date', '>=', $now);
|
||||
break;
|
||||
case 'after_1':
|
||||
$query->whereBetween('start_date', [$now, Carbon::now()->modify('+1 month')]);
|
||||
|
||||
break;
|
||||
case 'after_2':
|
||||
$query->whereBetween('start_date', [$now, Carbon::now()->modify('+2 month')]);
|
||||
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
$start = null;
|
||||
$end = null;
|
||||
if(Input::get('arrival_start_date') != ""){
|
||||
$arrStart = explode(".", Input::get('arrival_start_date'));
|
||||
if(count($arrStart) == 3){
|
||||
$start = Carbon::create($arrStart[2], $arrStart[1], $arrStart[0], 0, 0, 0);
|
||||
}
|
||||
}
|
||||
if(Input::get('arrival_end_date') != ""){
|
||||
$arrEnd = explode(".", Input::get('arrival_end_date'));
|
||||
if(count($arrEnd) == 3){
|
||||
$end = Carbon::create($arrEnd[2], $arrEnd[1], $arrEnd[0], 23, 59, 59);
|
||||
}
|
||||
}
|
||||
if($start && $end){
|
||||
$query->whereBetween('start_date', [$start, $end]);
|
||||
}
|
||||
if($start && !$end){
|
||||
$query->where('start_date', '>=', $start);
|
||||
}
|
||||
if(!$start && $end){
|
||||
$query->where('start_date', '<=', $end);
|
||||
}
|
||||
|
||||
$start = null;
|
||||
$end = null;
|
||||
if(Input::get('departure_start_date') != ""){
|
||||
$arrStart = explode(".", Input::get('departure_start_date'));
|
||||
if(count($arrStart) == 3){
|
||||
$start = Carbon::create($arrStart[2], $arrStart[1], $arrStart[0], 0, 0, 0);
|
||||
}
|
||||
}
|
||||
if(Input::get('departure_end_date') != ""){
|
||||
$arrEnd = explode(".", Input::get('departure_end_date'));
|
||||
if(count($arrEnd) == 3){
|
||||
$end = Carbon::create($arrEnd[2], $arrEnd[1], $arrEnd[0], 23, 59, 59);
|
||||
}
|
||||
}
|
||||
if($start && $end){
|
||||
$query->whereBetween('end_date', [$start, $end]);
|
||||
}
|
||||
if($start && !$end){
|
||||
$query->where('end_date', '>=', $start);
|
||||
}
|
||||
if(!$start && $end){
|
||||
$query->where('end_date', '<=', $end);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(Input::get('sort_travel_country_id') != ""){
|
||||
$query->where('travel_country_id', '=', Input::get('sort_travel_country_id'));
|
||||
}
|
||||
if(Input::get('sort_travelagenda_id') != ""){
|
||||
$query->where('travelagenda_id', '=', Input::get('sort_travelagenda_id'));
|
||||
}
|
||||
|
||||
if(Input::get('sort_sf_guard_user_id') != ""){
|
||||
$query->where('sf_guard_user_id', '=', Input::get('sort_sf_guard_user_id'));
|
||||
}
|
||||
|
||||
if(Input::get('sort_travel_documents') != ""){
|
||||
$query->where('travel_documents', '=', Input::get('sort_travel_documents'));
|
||||
}
|
||||
|
||||
|
||||
if(Input::get('full_lead_id_search') != ""){
|
||||
$query->where('lead_id', 'LIKE', '%'.Input::get('full_lead_id_search'). '%');
|
||||
}
|
||||
if(Input::get('full_booking_id_search') != ""){
|
||||
$query->where('id', 'LIKE', '%'.Input::get('full_booking_id_search').'%');
|
||||
}
|
||||
|
||||
//confirmation_code_remider is delete 2
|
||||
//
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action_edit', function (Booking $booking) {
|
||||
return ''; //'<a href="' . route('booking_detail', [$booking->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('lead_id', function (Booking $booking) {
|
||||
return '<a data-order="'.$booking->lead_id.'" href="'.make_old_url('leads/'.$booking->lead_id.'/edit').'" data-id="'.$booking->lead_id.'">'.$booking->lead_id.'</a>';
|
||||
})
|
||||
->addColumn('participant_firstname', function (Booking $booking) {
|
||||
return '<a data-order="'.$booking->participant_firstname.'" href="'.make_old_url('customer/'.$booking->customer_id.'/edit').'" data-id="'.$booking->customer_id.'">'.$booking->participant_firstname.'</a>';
|
||||
})
|
||||
->addColumn('participant_name', function (Booking $booking) {
|
||||
return '<a data-order="'.$booking->participant_name.'" href="'.make_old_url('customer/'.$booking->customer_id.'/edit').'" data-id="'.$booking->customer_id.'">'.$booking->participant_name.'</a>';
|
||||
})
|
||||
->addColumn('id', function (Booking $booking) {
|
||||
return '<a data-order="'.$booking->id.'" href="'.make_old_url('booking/'.$booking->id.'/edit').'" data-id="'.$booking->id.'">'.$booking->id.'</a>';
|
||||
})
|
||||
->addColumn('travel_country_id', function (Booking $booking) {
|
||||
return '<span data-order="'.($booking->travel_country_id ? $booking->travel_country_id : 0).'">'.($booking->travel_country_id ? $booking->travel_country->name : "-").'</span>';
|
||||
})
|
||||
->addColumn('travelagenda_id', function (Booking $booking) {
|
||||
return '<span data-order="'.($booking->travelagenda_id ? $booking->travelagenda_id : 0).'">'.($booking->travelagenda_id ? $booking->travel_agenda->name : "-").'</span>';
|
||||
})
|
||||
->addColumn('start_date', function (Booking $booking) {
|
||||
return $booking->getStartDateFormat();
|
||||
})
|
||||
->addColumn('end_date', function (Booking $booking) {
|
||||
return $booking->getEndDateFormat();
|
||||
})
|
||||
->addColumn('travel_documents', function (Booking $booking) {
|
||||
return $booking->travel_documents ? ' <span data-order="1" class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : '<span data-order="0" class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('sf_guard_user_id', function (Booking $booking) {
|
||||
return '<span data-order="'.($booking->sf_guard_user_id ? $booking->sf_guard_user_id : 0).'">'.($booking->sf_guard_user_id? $booking->sf_guard_user->first_name." ".$booking->sf_guard_user->last_name : "-").'</span>';
|
||||
})
|
||||
->addColumn('lead.status_id', function (Booking $booking) {
|
||||
return '<span data-order="'.($booking->lead->status_id ? $booking->lead->status_id : 0).'">'.($booking->lead->status_id ? $booking->lead->status->name : "-").'</span>';
|
||||
})
|
||||
/* ->filterColumn('travel_country_id', function($query, $keyword) {
|
||||
|
||||
if($keyword != "") {
|
||||
$query->whereRaw("travel_country_id = ?", $keyword);
|
||||
}
|
||||
|
||||
})
|
||||
->filterColumn('travelagenda_id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->whereRaw("travelagenda_id = ?", $keyword);
|
||||
|
||||
}
|
||||
})
|
||||
*/
|
||||
->orderColumn('lead_id', 'lead_id $1')
|
||||
->orderColumn('participant_firstname', 'participant_firstname $1')
|
||||
->orderColumn('participant_name', 'participant_name $1')
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('travel_country_id', 'travel_country_id $1')
|
||||
->orderColumn('travelagenda_id', 'travelagenda_id $1')
|
||||
->orderColumn('sf_guard_user_id', 'sf_guard_user_id $1')
|
||||
->orderColumn('start_date', 'start_date $1')
|
||||
->orderColumn('end_date', 'end_date $1')
|
||||
->orderColumn('travel_documents', 'travel_documents $1')
|
||||
->rawColumns(['action_edit', 'lead_id', 'participant_firstname', 'participant_name', 'travel_country_id', 'travelagenda_id', 'sf_guard_user_id', 'lead.status_id', 'id', 'travel_documents'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -108,12 +108,22 @@ class HomeController extends Controller
|
|||
return redirect(route('home'));
|
||||
}
|
||||
if($show == 'drafts'){
|
||||
return redirect(route('drafts'));
|
||||
return redirect(route('drafts'));
|
||||
}
|
||||
if(strpos($show, 'drafts_edit_booking_') !== false){
|
||||
$booking_id = str_replace('drafts_edit_booking_', '', $show);
|
||||
return redirect(route('booking_detail', [$booking_id]));
|
||||
}
|
||||
if($show == 'requests'){
|
||||
return redirect(route('requests'));
|
||||
}
|
||||
if($show == 'travel_agenda'){
|
||||
return redirect(route('admin_settings_travel_program'));
|
||||
}
|
||||
if($show == 'travel_country'){
|
||||
return redirect(route('admin_settings_travel_country'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
43
app/Http/Controllers/RequestController.php
Executable file
43
app/Http/Controllers/RequestController.php
Executable file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Booking;
|
||||
use Input;
|
||||
|
||||
class RequestController extends Controller
|
||||
{
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
}
|
||||
|
||||
public function index($step = false)
|
||||
{
|
||||
$data = [
|
||||
'step' => $step
|
||||
];
|
||||
return view('request.index', $data);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
wirte old where has state to new has travel_documents
|
||||
$bs = Booking::whereHas('arrangements', function($q){
|
||||
$q->where('state', '!=', NULL);
|
||||
})->where('lead_id', '!=', NULL)->where('new_drafts', 0)->get();
|
||||
|
||||
foreach ($bs as $b){
|
||||
$b->travel_documents = true;
|
||||
$b->save();
|
||||
var_dump($b->travel_documents);
|
||||
}
|
||||
die();
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
70
app/Http/Controllers/Settings/TravelAgendaController.php
Executable file
70
app/Http/Controllers/Settings/TravelAgendaController.php
Executable file
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\TravelAgenda;
|
||||
use App\Models\TravelCountry;
|
||||
use App\Models\TravelNationality;
|
||||
use App\Models\TravelNationalityRequirement;
|
||||
use Carbon\Carbon;
|
||||
use HTMLHelper;
|
||||
use Input;
|
||||
|
||||
class TravelAgendaController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
|
||||
}
|
||||
|
||||
public function index($step = false)
|
||||
{
|
||||
$data = [
|
||||
'travel_agenda' => TravelAgenda::all(),
|
||||
];
|
||||
return view('settings.travel_agenda.index', $data);
|
||||
}
|
||||
|
||||
|
||||
public function update(){
|
||||
|
||||
$data = Input::all();
|
||||
if($data['id'] == "new"){
|
||||
$model = TravelAgenda::create([
|
||||
'name' => $data['name'],
|
||||
'active' => isset($data['active']) ? true : false,
|
||||
'travelcountry_id' => $data['travelcountry_id'],
|
||||
|
||||
]);
|
||||
}else{
|
||||
$model = TravelAgenda::find($data['id']);
|
||||
$model->name = $data['name'];
|
||||
$model->active = isset($data['active']) ? true : false;
|
||||
$model->travelcountry_id = $data['travelcountry_id'];
|
||||
$model->save();
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_settings_travel_program'));
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
|
||||
if(Booking::where('travelagenda_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Eintrag wird verwendet');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$model = TravelAgenda::findOrFail($id);
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -4,6 +4,9 @@ namespace App\Http\Controllers\Settings;
|
|||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Models\TravelCountry;
|
||||
use App\Models\TravelNationality;
|
||||
use App\Models\TravelNationalityRequirement;
|
||||
use Carbon\Carbon;
|
||||
use HTMLHelper;
|
||||
use Input;
|
||||
|
|
@ -19,47 +22,88 @@ class TravelCountryController extends Controller
|
|||
public function index($step = false)
|
||||
{
|
||||
$data = [
|
||||
'drafts' => Draft::all()->sortByDesc("id"),
|
||||
'draft_types' => DraftType::all()->sortByDesc("id"),
|
||||
'step' => $step
|
||||
'travel_countries' => TravelCountry::all(),
|
||||
];
|
||||
return view('drafts.index', $data);
|
||||
return view('settings.travel_country.index', $data);
|
||||
}
|
||||
|
||||
|
||||
public function store(){
|
||||
|
||||
$data = Input::all();
|
||||
if($data['id'] == "new"){
|
||||
$draft_type = DraftType::create([
|
||||
'name' => $data['name'],
|
||||
'active' => isset($data['active']) ? true : false,
|
||||
'color' => $data['color'],
|
||||
]);
|
||||
public function detail($id)
|
||||
{
|
||||
if($id == "new") {
|
||||
$model = new TravelCountry();
|
||||
$id = 'new';
|
||||
$model->active_backend = 1;
|
||||
}else{
|
||||
$draft_type = DraftType::find($data['id']);
|
||||
$draft_type->name = $data['name'];
|
||||
$draft_type->active = isset($data['active']) ? true : false;
|
||||
$draft_type->color = $data['color'];
|
||||
|
||||
$draft_type->save();
|
||||
$model = TravelCountry::findOrFail($id);
|
||||
$id = $model->id;
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('drafts', ['type']));
|
||||
|
||||
$data = [
|
||||
'model' => $model,
|
||||
'id' => $id,
|
||||
'travel_nationalities' => TravelNationality::where('active', true)->get(),
|
||||
];
|
||||
return view('settings.travel_country.detail', $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function store(){
|
||||
|
||||
$data = Input::all();
|
||||
$data['is_customer_country'] = isset($data['is_customer_country']) ? true : false;
|
||||
$data['active_frontend'] = isset($data['active_frontend']) ? true : false;
|
||||
$data['active_backend'] = isset($data['active_backend']) ? true : false;
|
||||
|
||||
if($data['id'] == "new"){
|
||||
$data['crm_id'] = 0;
|
||||
$model = TravelCountry::create($data);
|
||||
}else{
|
||||
$model = TravelCountry::find($data['id']);
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
}
|
||||
|
||||
//travel_nationality_requirement
|
||||
if(isset($data['travel_nationality_requirement'])){
|
||||
foreach ($data['travel_nationality_requirement'] as $travel_nationality_id => $text){
|
||||
$model->setNationalityRequirement($travel_nationality_id, $text);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO for this thime
|
||||
//we need an update in the old CRM v1 system DB
|
||||
$tc = \App\Models\Sym\TravelCountry::find($model->crm_id);
|
||||
if(!$tc){
|
||||
$tc = \App\Models\Sym\TravelCountry::create($data);
|
||||
$model->crm_id = $tc->id;
|
||||
$model->save();
|
||||
}else{
|
||||
$tc->fill($data);
|
||||
$tc->save();
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_settings_travel_country_detail', [$model->id]));
|
||||
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
|
||||
if(DraftItem::where('draft_type_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Eintrag wird verwendet');
|
||||
return redirect(route('drafts'));
|
||||
$model = TravelCountry::findOrFail($id);
|
||||
if( $model->travel_nationality_requirements){
|
||||
foreach($model->travel_nationality_requirements as $travel_nationality_requirement){
|
||||
$travel_nationality_requirement->delete();
|
||||
}
|
||||
}
|
||||
$draft_type = DraftType::findOrFail($id);
|
||||
$draft_type->delete();
|
||||
$tc = \App\Models\Sym\TravelCountry::find($model->crm_id);
|
||||
if($tc){
|
||||
$tc->delete();
|
||||
}
|
||||
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect(route('drafts', ['type']));
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
65
app/Http/Controllers/Settings/TravelNationalityController.php
Executable file
65
app/Http/Controllers/Settings/TravelNationalityController.php
Executable file
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Models\TravelCountry;
|
||||
use App\Models\TravelNationality;
|
||||
use App\Models\TravelNationalityRequirement;
|
||||
use Carbon\Carbon;
|
||||
use HTMLHelper;
|
||||
use Input;
|
||||
|
||||
class TravelNationalityController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
|
||||
}
|
||||
|
||||
public function index($step = false)
|
||||
{
|
||||
$data = [
|
||||
'travel_nationality' => TravelNationality::all(),
|
||||
];
|
||||
return view('settings.travel_nationality.index', $data);
|
||||
}
|
||||
|
||||
|
||||
public function update(){
|
||||
|
||||
$data = Input::all();
|
||||
if($data['id'] == "new"){
|
||||
$model = TravelNationality::create([
|
||||
'name' => $data['name'],
|
||||
'active' => isset($data['active']) ? true : false,
|
||||
]);
|
||||
}else{
|
||||
$model = TravelNationality::find($data['id']);
|
||||
$model->name = $data['name'];
|
||||
$model->active = isset($data['active']) ? true : false;
|
||||
$model->save();
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_settings_travel_nationality'));
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
|
||||
if(TravelNationalityRequirement::where('travel_nationality_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Eintrag wird verwendet');
|
||||
return redirect()->back();
|
||||
}
|
||||
$model = TravelNationality::findOrFail($id);
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect()->back();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue