06 2022
This commit is contained in:
parent
34a3d2196b
commit
93d1bea8e3
45 changed files with 1601 additions and 573 deletions
67
app/Http/Controllers/Settings/TravelCategoryController.php
Normal file
67
app/Http/Controllers/Settings/TravelCategoryController.php
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\TravelCategory;
|
||||
use Request;
|
||||
|
||||
class TravelCategoryController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware(['superadmin', '2fa']);
|
||||
}
|
||||
|
||||
public function index($step = false)
|
||||
{
|
||||
$data = [
|
||||
'travel_category' => TravelCategory::all(),
|
||||
];
|
||||
return view('settings.travel_category.index', $data);
|
||||
}
|
||||
|
||||
|
||||
public function update(){
|
||||
|
||||
$data = Request::all();
|
||||
if($data['id'] === "new"){
|
||||
$model = TravelCategory::create([
|
||||
'name' => $data['name'],
|
||||
'active' => isset($data['active']) ? true : false
|
||||
|
||||
]);
|
||||
}else{
|
||||
$model = TravelCategory::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_category'));
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
|
||||
$model = TravelCategory::findOrFail($id);
|
||||
if($model->bookings->count() > 0){
|
||||
\Session()->flash('alert-error', 'Eintrag wird bei Buchnungen verwendet');
|
||||
return redirect()->back();
|
||||
}
|
||||
if($model->travel_programs->count() > 0){
|
||||
\Session()->flash('alert-error', 'Eintrag wird bei Programmen verwendet');
|
||||
return redirect()->back();
|
||||
}
|
||||
if($model->leads->count() > 0){
|
||||
\Session()->flash('alert-error', 'Eintrag wird bei Anfragen verwendet');
|
||||
return redirect()->back();
|
||||
}
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue