Travel Guide Frontend Backend
This commit is contained in:
parent
e6cc042aee
commit
0857a34766
681 changed files with 6680 additions and 1689 deletions
138
app/Http/Controllers/CMS/CMSAnswerQuestionController.php
Executable file
138
app/Http/Controllers/CMS/CMSAnswerQuestionController.php
Executable file
|
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\CMS;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\AnswerQuestion;
|
||||
use App\Models\IQContentCategory;
|
||||
use IqContent\LaravelFilemanager\Lfm;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
|
||||
class CMSAnswerQuestionController extends Controller
|
||||
{
|
||||
|
||||
/*
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected $identifier_options;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->identifier_options = IQContentCategory::where('identifier', 'faq')
|
||||
->where('active', true)
|
||||
->orderBy('pos', 'ASC')
|
||||
->get()->pluck('name','id');
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
'models' => AnswerQuestion::all(),
|
||||
'identifier_options' => $this->identifier_options,
|
||||
];
|
||||
return view('cms.answer_question.index', $data);
|
||||
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
if($id === "new") {
|
||||
$model = new AnswerQuestion();
|
||||
$id = 'new';
|
||||
$model->status = 1;
|
||||
|
||||
}else{
|
||||
$model = AnswerQuestion::findOrFail($id);
|
||||
$id = $model->id;
|
||||
}
|
||||
$data = [
|
||||
'model' => $model,
|
||||
'id' => $id,
|
||||
'identifier_options' => $this->identifier_options,
|
||||
'lfm_helper' => app(Lfm::class),
|
||||
|
||||
];
|
||||
return view('cms.answer_question.detail', $data);
|
||||
}
|
||||
|
||||
public function store($id)
|
||||
{
|
||||
$data = Request::all();
|
||||
|
||||
$rules = array(
|
||||
'question' => 'required',
|
||||
);
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator);
|
||||
}
|
||||
|
||||
if($id === "new") {
|
||||
$model = AnswerQuestion::create($data);
|
||||
}else{
|
||||
$model = AnswerQuestion::findOrFail($data['id']);
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
}
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('cms_answer_question_detail', [$model->id]));
|
||||
}
|
||||
|
||||
|
||||
public function delete($id){
|
||||
$model = AnswerQuestion::findOrFail($id);
|
||||
//TODO
|
||||
//check for use?
|
||||
|
||||
// die("check for use");
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', __('Eintrag gelöscht'));
|
||||
return redirect(route('cms_answer_question'));
|
||||
}
|
||||
|
||||
|
||||
public function datatable(){
|
||||
|
||||
$query = AnswerQuestion::with('iq_content_category')->select('answer_questions.*');
|
||||
|
||||
if(Request::get('filter_identifier_options') != ""){
|
||||
$query->where('i_q_content_category_id', '=', Request::get('filter_identifier_options'));
|
||||
}
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
|
||||
->addColumn('action_edit', function (AnswerQuestion $faq) {
|
||||
return '<a href="'.route('cms_answer_question_detail', [$faq->id]).'" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('category', function (AnswerQuestion $faq) {
|
||||
return $faq->iq_content_category ? $faq->iq_content_category->name : '';
|
||||
})
|
||||
->addColumn('created_at', function (AnswerQuestion $faq) {
|
||||
return $faq->created_at->format('d.m.Y');
|
||||
})
|
||||
->addColumn('active', function (AnswerQuestion $faq) {
|
||||
return get_active_badge($faq->active);
|
||||
})
|
||||
->addColumn('delete', function (AnswerQuestion $faq) {
|
||||
return '<a class="text-danger" href="'.route('cms_answer_question_delete', [$faq->id]).'" onclick="return confirm(\'Wirklich löschen?\');"><i class="fa fa-trash-alt"></i></a>';
|
||||
})
|
||||
|
||||
->orderColumn('action_edit', 'id $1')
|
||||
->orderColumn('category', 'i_q_content_category_id $1')
|
||||
->orderColumn('created_at', 'created_at $1')
|
||||
->orderColumn('active', 'active $1')
|
||||
|
||||
|
||||
->rawColumns(['action_edit', 'active', 'delete'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue