forked from mirror/pixelfed
Update PageController
This commit is contained in:
parent
aca5114fcb
commit
59fcfc2779
1 changed files with 25 additions and 1 deletions
|
@ -3,7 +3,7 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
use Auth, Cache;
|
||||
use App\Page;
|
||||
|
||||
class PageController extends Controller
|
||||
|
@ -13,6 +13,14 @@ class PageController extends Controller
|
|||
$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)
|
||||
{
|
||||
$auth = $admin_only ?
|
||||
|
@ -48,9 +56,25 @@ class PageController extends Controller
|
|||
$page->title = $request->input('title');
|
||||
$page->active = (bool) $request->input('active');
|
||||
$page->save();
|
||||
if($page->cached) {
|
||||
$keys = $this->cacheKeys();
|
||||
$key = $keys[$page->slug];
|
||||
Cache::forget($key);
|
||||
}
|
||||
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)
|
||||
{
|
||||
$this->validate($request, [
|
||||
|
|
Loading…
Reference in a new issue