70 lines
1.7 KiB
PHP
Executable file
70 lines
1.7 KiB
PHP
Executable file
<?php
|
|
|
|
namespace App\Http\Controllers\Settings;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Models\Airline;
|
|
use App\Models\Booking;
|
|
use App\Services\Util;
|
|
use Request;
|
|
|
|
class AirlineController extends Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->middleware('admin');
|
|
|
|
}
|
|
|
|
public function index($step = false)
|
|
{
|
|
$data = [
|
|
'airline' => Airline::all(),
|
|
];
|
|
return view('settings.airline.index', $data);
|
|
}
|
|
|
|
|
|
public function update(){
|
|
|
|
$data = Request::all();
|
|
|
|
|
|
$data['contact_emails'] = isset($data['contact_emails']) ? Util::_explodeLines($data['contact_emails']) : null;
|
|
|
|
if($data['id'] === "new"){
|
|
$model = Airline::create($data);
|
|
}else{
|
|
$model = Airline::find($data['id']);
|
|
$model->name = $data['name'];
|
|
$model->name_full = $data['name_full'];
|
|
$model->contact_emails = $data['contact_emails'];
|
|
$model->save();
|
|
}
|
|
|
|
\Session()->flash('alert-save', '1');
|
|
return redirect(route('admin_settings_airline'));
|
|
}
|
|
|
|
public function delete($id){
|
|
//TODO check ist linked
|
|
/*if(Booking::where('travelagenda_id', $id)->count()){
|
|
\Session()->flash('alert-error', 'Eintrag wird verwendet');
|
|
return redirect()->back();
|
|
}*/
|
|
|
|
$model = Airline::findOrFail($id);
|
|
|
|
if(Booking::where('airline_id', $model->id)->count()){
|
|
\Session()->flash('alert-error', 'Fehler: Airline in Buchnungen verwendet.');
|
|
return redirect()->back();
|
|
}
|
|
$model->delete();
|
|
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
|
return redirect()->back();
|
|
}
|
|
|
|
}
|
|
|
|
|