Skip to content

Commit

Permalink
Page controller rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
ttimot24 committed Sep 30, 2024
1 parent 9aeaedf commit b4c73bc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 26 deletions.
36 changes: 12 additions & 24 deletions app/Controllers/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

use App\Controllers\Trait\UploadsImage;
use Illuminate\Http\Request;
use App\Libs\Controller;
use Illuminate\Routing\Controller;
use App\Model\Page;

// TODO
class PageController extends Controller
{

Expand Down Expand Up @@ -39,13 +38,10 @@ public function index(Request $request)
return response()->json($pages);
}

// TODO
$this->view->js('resources/js/dragndrop.js');

return view('pages.index', [
'all_pages' => $pages,
'visible_pages' => Page::where('visibility', 1)->count(),
'home_page' => Page::find($this->request->settings['home_page']),
'home_page' => Page::find($request->settings['home_page']),
]);
}

Expand All @@ -56,8 +52,6 @@ public function index(Request $request)
*/
public function create(Request $request)
{
// TODO
$this->view->js('resources/js/pages.js');

return view('pages.form', [
'all_page' => Page::all(),
Expand All @@ -84,11 +78,11 @@ public function store(Request $request)

$this->uploadImage($page);

if ($page->save()) {
if($page->save()) {
return redirect(route("page.edit", ['page' => $page]))->withMessage(['success' => trans('message.successfully_created_page')]);
} else {
return redirect()->back()->withMessage(['danger' => trans('message.something_went_wrong')]);
}
}

return redirect()->back()->withMessage(['danger' => trans('message.something_went_wrong')]);
}

/**
Expand All @@ -114,8 +108,6 @@ public function show(Request $request, Page $page)
*/
public function edit(Request $request, Page $page)
{
// TODO
$this->view->js('resources/js/pages.js');

return view('pages.form', [
'page' => $page,
Expand Down Expand Up @@ -146,9 +138,9 @@ public function update(Request $request, Page $page)

if ($page->save()) {
return redirect(route("page.edit", ['page' => $page]))->withMessage(['success' => trans('message.successfully_updated_page')]);
} else {
return redirect()->back()->withMessage(['danger' => trans('message.something_went_wrong')]);
}
}

return redirect()->back()->withMessage(['danger' => trans('message.something_went_wrong')]);
}


Expand All @@ -157,9 +149,9 @@ public function setHomePage($id)

if (\App\Model\Settings::where("setting", "home_page")->update(['value' => $id])) {
return redirect()->back()->withMessage(['success' => trans('message.successfully_set_homepage')]);
} else {
return redirect()->back()->withMessage(['danger' => trans('message.something_went_wrong')]);
}
}

return redirect()->back()->withMessage(['danger' => trans('message.something_went_wrong')]);
}


Expand All @@ -176,13 +168,9 @@ public function destroy(Page $page)
return redirect(route("page.index"))->withMessage(['success' => trans('message.successfully_deleted_page')]);
}


return redirect(route("page.index"))->withMessage(['danger' => trans('message.something_went_wrong')]);
}




public function reorder()
{

Expand Down
2 changes: 1 addition & 1 deletion app/View/pages/form.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@extends('layout', ['title' => isset($page)? trans('page.edit_page') : trans('page.new_page')])
@extends('layout', ['title' => isset($page)? trans('page.edit_page') : trans('page.new_page'), 'js' => array_merge($js, ['resources/js/pages.js'])])

@section('content')
<div class='container main-container'>
Expand Down
2 changes: 1 addition & 1 deletion app/View/pages/index.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@extends('layout', ['title' => trans('page.pages'), 'js' => ['resources/js/dragndrop.js'] ])
@extends('layout', ['title' => trans('page.pages'), 'js' => array_merge($js, ['resources/js/dragndrop.js']) ])

@section('content')
<div class='container main-container'>
Expand Down

0 comments on commit b4c73bc

Please sign in to comment.