last changes since 6-2023
This commit is contained in:
parent
561c5875a7
commit
c1c613a4b9
53 changed files with 1351 additions and 93 deletions
154
app/Http/Controllers/TravelContentController.php
Normal file
154
app/Http/Controllers/TravelContentController.php
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Request;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Page;
|
||||
|
||||
class TravelContentController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware(['admin', '2fa']);
|
||||
}
|
||||
|
||||
public function index($step = false)
|
||||
{
|
||||
$data = [
|
||||
'travelProgramOverviews' => Page::whereTemplate('travelProgramOverview')->get(),
|
||||
'step' => $step
|
||||
];
|
||||
return view('travel.content.index', $data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
if($id === "new") {
|
||||
$id = 'new';
|
||||
|
||||
}else{
|
||||
$page = Page::findOrFail($id);
|
||||
$id = $page->id;
|
||||
}
|
||||
$data = [
|
||||
'model' => $page,
|
||||
'id' => $id,
|
||||
];
|
||||
return view('travel.content.detail', $data);
|
||||
}
|
||||
|
||||
public function store($id)
|
||||
{
|
||||
$data = Request::all();
|
||||
if($id === "new") {
|
||||
//$draft = new Draft();
|
||||
}else{
|
||||
$page = Page::findOrFail($id);
|
||||
}
|
||||
|
||||
if(Page::whereSlug($data['slug'])->where('id', '!=', $page->id)->count() > 0){
|
||||
$data['slug'] = "";
|
||||
}
|
||||
|
||||
$page->title = $data['title'];
|
||||
$page->title_short = $data['title_short'];
|
||||
$page->pagetitle = $data['pagetitle'];
|
||||
$page->slug = $data['slug'];
|
||||
$page->description = $data['description'];
|
||||
$page->content_new = $data['content_new'];
|
||||
$page->status = $data['status'];
|
||||
$page->show_in_navi = $data['show_in_navi'];
|
||||
$page->save();
|
||||
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('travel_content_detail', [$page->id]));
|
||||
}
|
||||
|
||||
public function subDetail($id)
|
||||
{
|
||||
if($id === "new") {
|
||||
$id = 'new';
|
||||
|
||||
}else{
|
||||
$page = Page::findOrFail($id);
|
||||
$id = $page->id;
|
||||
}
|
||||
$data = [
|
||||
'model' => $page,
|
||||
'id' => $id,
|
||||
];
|
||||
return view('travel.content.sub_detail', $data);
|
||||
}
|
||||
|
||||
public function subStore($id)
|
||||
{
|
||||
$data = Request::all();
|
||||
if($id === "new") {
|
||||
//$draft = new Draft();
|
||||
}else{
|
||||
$page = Page::findOrFail($id);
|
||||
}
|
||||
|
||||
if(Page::whereSlug($data['slug'])->where('id', '!=', $page->id)->count() > 0){
|
||||
$data['slug'] = "";
|
||||
}
|
||||
$page->title = $data['title'];
|
||||
$page->pagetitle = $data['pagetitle'];
|
||||
$page->slug = $data['slug'];
|
||||
$page->description = $data['description'];
|
||||
$page->status = $data['status'];
|
||||
$page->show_in_navi = $data['show_in_navi'];
|
||||
$page->order = $data['order'];
|
||||
|
||||
$page->travel_program = $data['travel_program'] > 0 ? $data['travel_program'] : null;
|
||||
|
||||
$page->save();
|
||||
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('travel_content_sub_detail', [$page->id]));
|
||||
}
|
||||
|
||||
|
||||
public function load(){
|
||||
$data = Request::all();
|
||||
$ret = "";
|
||||
if(Request::ajax()) {
|
||||
if($data['action'] === "modal-copy-page") {
|
||||
if($data['id'] > 0){
|
||||
$value = Page::findOrFail($data['id']);
|
||||
$ret = view('travel.content.modal_copy', compact('value'))->render();
|
||||
}
|
||||
}
|
||||
}
|
||||
return response()->json(['response' => $data, 'html'=>$ret]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function update(){
|
||||
|
||||
$data = Request::all();
|
||||
|
||||
if($data['action'] === 'page-copy'){
|
||||
if($data['page_copy_id'] > 0){
|
||||
$model = Page::findOrFail($data['page_copy_id']);
|
||||
$newModel = $model->replicate();
|
||||
$newModel->date = null;
|
||||
//slug unique
|
||||
// $newModel->slug
|
||||
$newModel->created_at = now();
|
||||
$newModel->save();
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('travel_content_detail', [$data['id']]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue