58 lines
1.3 KiB
PHP
Executable file
58 lines
1.3 KiB
PHP
Executable file
<?php
|
|
|
|
namespace App\Http\Controllers\Settings;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Models\Keyword;
|
|
use Request;
|
|
|
|
class KeywordController extends Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->middleware('admin');
|
|
|
|
}
|
|
|
|
public function index($step = false)
|
|
{
|
|
$data = [
|
|
'keywords' => Keyword::all(),
|
|
];
|
|
return view('settings.keywords.index', $data);
|
|
}
|
|
|
|
|
|
public function update(){
|
|
|
|
$data = Request::all();
|
|
if($data['id'] === "new"){
|
|
$model = Keyword::create([
|
|
'name' => $data['name'],
|
|
]);
|
|
}else{
|
|
$model = Keyword::find($data['id']);
|
|
$model->name = $data['name'];
|
|
$model->save();
|
|
}
|
|
|
|
\Session()->flash('alert-save', '1');
|
|
return redirect(route('admin_settings_keyword'));
|
|
}
|
|
|
|
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 = Keyword::findOrFail($id);
|
|
$model->delete();
|
|
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
|
return redirect()->back();
|
|
}
|
|
|
|
}
|
|
|
|
|