Fewo Mails / Booking Country Services
This commit is contained in:
parent
b9c26d06d0
commit
48a6eb2282
154 changed files with 7761 additions and 1643 deletions
|
|
@ -4,9 +4,14 @@ namespace App\Http\Controllers\Settings;
|
|||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Models\GeneralFile;
|
||||
use App\Models\TravelCountry;
|
||||
use App\Models\TravelCountryService;
|
||||
use App\Models\TravelNationality;
|
||||
use App\Repositories\CustomerFileRepository;
|
||||
use App\Repositories\GeneralFileRepository;
|
||||
use App\Services\Util;
|
||||
use IqContent\LaravelFilemanager\Lfm;
|
||||
use Request;
|
||||
|
||||
class TravelCountryController extends Controller
|
||||
|
|
@ -48,27 +53,45 @@ class TravelCountryController extends Controller
|
|||
'id' => $id,
|
||||
'step' => $step,
|
||||
'travel_nationalities' => TravelNationality::where('active', true)->get(),
|
||||
'lfm_helper' => app(Lfm::class),
|
||||
|
||||
];
|
||||
return view('settings.travel_country.detail', $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function update($id)
|
||||
{
|
||||
|
||||
$data = Request::all();
|
||||
|
||||
if(isset($data['update-action'])){
|
||||
if($data['update-action'] === 'save-travel-county-service'){
|
||||
$data['active'] = true;//isset($data['active']) ? true : false;
|
||||
$travel_country = TravelCountry::findOrFail($id);
|
||||
$data['travel_country_id'] = $travel_country->id;
|
||||
$data['crm_travel_country_id'] = $travel_country->crm_id;
|
||||
if($data['travel_county_service_id'] === 'new'){
|
||||
$model = TravelCountryService::create($data);
|
||||
}else{
|
||||
$model = TravelCountryService::find($data['travel_county_service_id']);
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
}
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect($data['back']);
|
||||
}
|
||||
}
|
||||
|
||||
$data['contact_emails'] = isset($data['contact_emails']) ? Util::_explodeLines($data['contact_emails']) : null;
|
||||
if(!isset($data['contact_lands'])){
|
||||
$data['contact_lands'] = null;
|
||||
}
|
||||
$data['action'] = isset($data['action']) ? $data['action'] : false;
|
||||
/*
|
||||
* $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($id === "new"){
|
||||
$data['crm_id'] = 0;
|
||||
$model = TravelCountry::create($data);
|
||||
}else{
|
||||
$model = TravelCountry::find($id);
|
||||
|
|
@ -82,41 +105,64 @@ class TravelCountryController extends Controller
|
|||
$model->setNationalityRequirement($travel_nationality_id, $text);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO for this time
|
||||
if ($data['action'] === 'contact') {
|
||||
//we need an update in the old CRM v1 system DB
|
||||
$tc = \App\Models\Sym\TravelCountry::findOrFail($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();
|
||||
}
|
||||
|
||||
$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]));
|
||||
return redirect(route('admin_settings_travel_country_detail', [$model->id, $data['action']]));
|
||||
}
|
||||
|
||||
|
||||
public function delete($id){
|
||||
$model = TravelCountry::findOrFail($id);
|
||||
if( $model->travel_nationality_requirements){
|
||||
foreach($model->travel_nationality_requirements as $travel_nationality_requirement){
|
||||
$travel_nationality_requirement->delete();
|
||||
public function delete($id, $del="travel_country"){
|
||||
|
||||
if($del === 'travel_country'){
|
||||
$model = TravelCountry::findOrFail($id);
|
||||
if($model->travel_nationality_requirements){
|
||||
foreach($model->travel_nationality_requirements as $travel_nationality_requirement){
|
||||
$travel_nationality_requirement->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
$tc = \App\Models\Sym\TravelCountry::find($model->crm_id);
|
||||
if($tc){
|
||||
$tc->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()->back();
|
||||
}
|
||||
|
||||
if($del === 'general_file'){
|
||||
$general_file = GeneralFile::findOrFail($id);
|
||||
$travel_country = $general_file->travel_country;
|
||||
$fileRepo = new GeneralFileRepository($general_file);
|
||||
$fileRepo->_set('disk', 'general');
|
||||
$fileRepo->delete();
|
||||
$general_file->delete();
|
||||
\Session()->flash('alert-success', 'Datei gelöscht');
|
||||
return redirect(route('admin_settings_travel_country_detail', [$travel_country->id, 'data']));
|
||||
|
||||
}
|
||||
if($del === 'country_service'){
|
||||
$travel_country_service = TravelCountryService::findOrFail($id);
|
||||
$travel_country = $travel_country_service->travel_country;
|
||||
//check as entry
|
||||
if($travel_country_service->booking_country_services->count() > 0){
|
||||
\Session()->flash('alert-error', 'Die Leistung kann nicht gelöscht werden, diese hat Einträge bei den Buchungen');
|
||||
return redirect(route('admin_settings_travel_country_detail', [$travel_country->id, 'services']));
|
||||
}
|
||||
$travel_country_service->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect(route('admin_settings_travel_country_detail', [$travel_country->id, 'services']));
|
||||
|
||||
}
|
||||
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue