IQ Reisebausteine bis Gruppe
This commit is contained in:
parent
6880c7e989
commit
9baa1a6233
43 changed files with 2206 additions and 24 deletions
136
app/Http/Controllers/IQ/TravelItemController.php
Normal file
136
app/Http/Controllers/IQ/TravelItemController.php
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\IQ;
|
||||
|
||||
use Request;
|
||||
use App\Models\IQTravelItem;
|
||||
use App\Models\IQTravelItemPlace;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\IQ\TravelRepository;
|
||||
|
||||
class TravelItemController extends Controller
|
||||
{
|
||||
|
||||
protected $tavelRepo;
|
||||
|
||||
|
||||
public function __construct(TravelRepository $tavelRepo)
|
||||
{
|
||||
$this->middleware('admin');
|
||||
$this->tavelRepo = $tavelRepo;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
|
||||
];
|
||||
return view('iq.travel.item.index', $data);
|
||||
}
|
||||
|
||||
|
||||
public function detail($id, $step = false)
|
||||
{
|
||||
if($id === "new") {
|
||||
$model = new IQTravelItem();
|
||||
$id = 'new';
|
||||
$model->active = 1;
|
||||
}else{
|
||||
$model = IQTravelItem::findOrFail($id);
|
||||
$id = $model->id;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'model' => $model,
|
||||
'id' => $id,
|
||||
|
||||
];
|
||||
return view('iq.travel.item.detail', $data);
|
||||
}
|
||||
|
||||
|
||||
public function store($id)
|
||||
{
|
||||
$data = Request::all();
|
||||
if(isset($data['action'])){
|
||||
if($data['action'] === 'saveAll'){
|
||||
$travel_item = $this->tavelRepo->updateTravelItem($id, $data);
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('iq_travel_item_detail', [$travel_item->id]));
|
||||
|
||||
}
|
||||
if($data['action'] === 'save-iq_travel_item_place'){
|
||||
$travel_item_place = $this->tavelRepo->updateTravelItemPlace($id, $data);
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('iq_travel_item_detail', [$id]));
|
||||
|
||||
}
|
||||
}
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function delete($id, $del=false){
|
||||
if($del === 'i_q_travel_item_place'){
|
||||
$IQTravelItemPlace = IQTravelItemPlace::findOrFail($id);
|
||||
$r_id = $IQTravelItemPlace->i_q_travel_item_id;
|
||||
//TODO check need ???
|
||||
$IQTravelItemPlace->delete();
|
||||
\Session()->flash('alert-success', __('Eintrag gelöscht'));
|
||||
return redirect(route('iq_travel_item_detail', [$r_id]));
|
||||
}
|
||||
if($del === 'iq_travel_item'){
|
||||
$IQTravelItem = IQTravelItem::findOrFail($id);
|
||||
//TODO check need ???
|
||||
$IQTravelItem->delete();
|
||||
\Session()->flash('alert-success', __('Eintrag gelöscht'));
|
||||
return redirect(route('iq_travel_items'));
|
||||
}
|
||||
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
public function getTravelItems()
|
||||
{
|
||||
$query = IQTravelItem::with('draft_type')->with('i_q_travel_item_places')->select('i_q_travel_items.*');
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action_edit', function (IQTravelItem $iq_travel_item) {
|
||||
return '<a href="'.route('iq_travel_item_detail', [$iq_travel_item->id]).'" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('draft_type', function (IQTravelItem $iq_travel_item) {
|
||||
return $iq_travel_item->draft_type ? '<span class="py-1 px-2" style="background-color:'.$iq_travel_item->draft_type->color.'">'.$iq_travel_item->draft_type->name.'</span>' : '';
|
||||
})
|
||||
->addColumn('country', function (IQTravelItem $iq_travel_item) {
|
||||
return $iq_travel_item->travel_country ? $iq_travel_item->travel_country->name : '';
|
||||
})
|
||||
->addColumn('trave_places', function (IQTravelItem $iq_travel_item) {
|
||||
$ret = "";
|
||||
if($iq_travel_item->i_q_travel_item_places->count()){
|
||||
foreach($iq_travel_item->i_q_travel_item_places as $i_q_travel_item_place){
|
||||
$ret .= $i_q_travel_item_place->travel_place->name."<br>";
|
||||
}
|
||||
$ret = rtrim($ret, '<br>');
|
||||
}
|
||||
return $ret;
|
||||
})
|
||||
->addColumn('active', function (IQTravelItem $iq_travel_item) {
|
||||
return get_active_badge($iq_travel_item->active);
|
||||
})
|
||||
/*
|
||||
->filterColumn('draft_type', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereHas('draft_type', function ($q) use ($keyword) {
|
||||
$q->where("name", 'LIKE', '%' . $keyword . '%');
|
||||
});
|
||||
}
|
||||
})
|
||||
*/
|
||||
->addColumn('action_delete', function (IQTravelItem $iq_travel_item) {
|
||||
return '<a href="' . route('iq_travel_item_delete', [$iq_travel_item->id, 'iq_travel_item']) . '" class="btn icon-btn btn-sm btn-danger" onclick="return confirm(\''.__('Really delete entry?').'\');"><span class="fa fa-trash"></span></a>';
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->rawColumns(['action_edit', 'id', 'active', 'draft_type', 'trave_places', 'action_delete'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue