mirror of https://github.com/pixelfed/pixelfed.git
Update PageController
This commit is contained in:
parent
aca5114fcb
commit
59fcfc2779
|
@ -3,7 +3,7 @@
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Auth;
|
use Auth, Cache;
|
||||||
use App\Page;
|
use App\Page;
|
||||||
|
|
||||||
class PageController extends Controller
|
class PageController extends Controller
|
||||||
|
@ -13,6 +13,14 @@ class PageController extends Controller
|
||||||
$this->middleware(['auth', 'admin']);
|
$this->middleware(['auth', 'admin']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function cacheKeys() {
|
||||||
|
return [
|
||||||
|
'/site/about' => 'site:about',
|
||||||
|
'/site/privacy' => 'site:privacy',
|
||||||
|
'/site/terms' => 'site:terms',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
protected function authCheck($admin_only = false)
|
protected function authCheck($admin_only = false)
|
||||||
{
|
{
|
||||||
$auth = $admin_only ?
|
$auth = $admin_only ?
|
||||||
|
@ -48,9 +56,25 @@ class PageController extends Controller
|
||||||
$page->title = $request->input('title');
|
$page->title = $request->input('title');
|
||||||
$page->active = (bool) $request->input('active');
|
$page->active = (bool) $request->input('active');
|
||||||
$page->save();
|
$page->save();
|
||||||
|
if($page->cached) {
|
||||||
|
$keys = $this->cacheKeys();
|
||||||
|
$key = $keys[$page->slug];
|
||||||
|
Cache::forget($key);
|
||||||
|
}
|
||||||
return response()->json(['msg' => 200]);
|
return response()->json(['msg' => 200]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete(Request $request)
|
||||||
|
{
|
||||||
|
$this->validate($request, [
|
||||||
|
'id' => 'required|integer|min:1|exists:pages,id'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$page = Page::findOrFail($request->input('id'));
|
||||||
|
$page->delete();
|
||||||
|
return redirect(route('admin.settings.pages'));
|
||||||
|
}
|
||||||
|
|
||||||
public function generatePage(Request $request)
|
public function generatePage(Request $request)
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
|
|
Loading…
Reference in New Issue